/* Bouwplan: the shared parts of the pages (fields, sections, tables, dashboards, reports), same look as the prototype.
   base.css stays as the base has it; everything Bouwplan adds is here. Page specific css is in pages/<name>/<name>.css. */

.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Topbar additions: the logo goes to the general dashboard, the project picker in the middle ---------- */
x-topbar .brand .logo, x-topbar .brand .name { cursor: pointer; }
x-topbar .middle { display: flex; align-items: center; padding: 0 20px; }
@media (max-width: 767px) {
  x-topbar .middle { padding: 0 6px; }
}

/* ---------- Buttons (additions to .button of base.css) ---------- */
.button .ic { width: 18px; height: 18px; }
.button.danger { background: var(--danger); border-color: var(--danger); color: #ffffff; }
.button.danger:hover { background: var(--danger); filter: brightness(0.92); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.small { height: 30px; padding: 0 10px; font-size: 12.5px; }
.button.small .ic { width: 16px; height: 16px; }
.modal-note { font-size: 13.5px; color: var(--fg-2); }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; font-size: 12.5px; display: grid; place-items: center; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.muted { background: var(--muted-soft); color: var(--fg-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.muted { background: var(--line-strong); }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--fg-3); }

/* ---------- Page layouts ---------- */
.page.with-sidebar > x-detail.content { overflow: hidden; }
.page.single { height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); padding: 20px 24px; }
.page.dash { padding: 24px; }
.dash-inner { max-width: 1320px; margin: 0 auto; }
.dash-head { margin-bottom: 20px; }
.page .page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.page-sub { color: var(--fg-3); margin-top: 2px; }
.page.placeholder { height: 100%; padding: 20px 24px; }
.page.placeholder > .panel { height: 100%; display: grid; place-items: center; text-align: center; padding: 40px; }
.page.placeholder h1 { font-size: 20px; margin-bottom: 6px; }
.page.placeholder p { color: var(--fg-3); }

@media (max-width: 1099px) {
  .page.single { padding: 16px; }
}
@media (max-width: 767px) {
  .page.with-sidebar > x-detail.content { padding: 0; overflow: visible; }
  .page.single { height: auto; display: block; padding: 0; }
  .page.dash { padding: 16px; }
  .page.placeholder { height: auto; padding: 16px; }
}

/* ---------- Sections and fields (inside x-detail) ---------- */
.section { max-width: 1120px; }
.section + .section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-title { font-size: 14px; font-weight: 600; color: var(--fg); }
.section-note { color: var(--fg-3); font-size: 13px; margin-bottom: 14px; max-width: 760px; }

.fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 20px; }
@container (max-width: 600px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 400px) { .fields { grid-template-columns: minmax(0, 1fr); } .fields .field.span2 { grid-column: auto; } }
.field { min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.span2 { grid-column: span 2; }
.field .field-label { display: block; font-size: 14px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }

.input::placeholder { color: var(--fg-3); }
.input:hover { border-color: var(--fg-3); }
.input[readonly] { background: var(--zebra); border-color: var(--line); color: var(--fg-2); }
textarea.input { height: auto; min-height: 220px; padding: 14px 16px; line-height: 1.65; resize: none; overflow: hidden; max-width: 860px; display: block; }
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2356626e' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
}
:root[data-theme="dark"] select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa6b2' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

.range { display: flex; align-items: center; gap: 8px; }
.range .input { min-width: 0; }
.range span { color: var(--fg-3); font-size: 13px; }

.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; margin: 0; font-weight: 400; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 40px; height: 24px; border-radius: 12px; background: var(--line-strong); position: relative; transition: background 0.3s var(--ease); flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.3s var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { color: var(--fg-2); font-size: 13.5px; }

.checks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; }
@container (max-width: 760px) { .checks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 400px) { .checks { grid-template-columns: minmax(0, 1fr); } }
.check { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); cursor: pointer; transition: border-color 0.25s var(--ease), background 0.25s var(--ease); }
.check:hover { border-color: var(--line-strong); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Tables and lists ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 13px; color: var(--fg-2); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody tr:nth-child(even) td { background: var(--zebra); }
.table tr:last-child td { border-bottom: 0; }
.table td.number, .table th.number { text-align: right; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--line); }
.table .switch { min-height: 0; }
.table a { color: var(--accent-strong); }
.table .strong { font-weight: 600; }

.list-rows { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--input-bg); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--input-bg); width: 100%; text-align: left; }
.list-row:last-child { border-bottom: 0; }
.list-row:nth-child(even) { background: var(--zebra); }
button.list-row { cursor: pointer; }
button.list-row:hover { background: var(--line); }
.list-row .main { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { color: var(--fg-3); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .date { flex: none; width: 100px; color: var(--fg-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty-box { border: 1px dashed var(--line-strong); border-radius: 6px; padding: 36px 24px; text-align: center; color: var(--fg-3); max-width: 1120px; background: var(--input-bg); }
.empty-box .empty-title { color: var(--fg); font-weight: 600; margin-bottom: 4px; }
.list-empty { padding: 24px 16px; text-align: center; color: var(--fg-3); font-size: 13px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--fg-3); }
.facts dd { margin: 0; font-weight: 500; }

/* Derived figures (Project > Algemeen) */
.summary-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@container (max-width: 600px) { .summary-cards { grid-template-columns: minmax(0, 1fr); } }
.summary-card { border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); padding: 16px 18px; }
.summary-card h4 { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.summary-card .lead { color: var(--fg-3); font-size: 13px; margin-bottom: 12px; }
.summary-card .facts { gap: 8px 20px; }
.summary-card .facts dd { font-variant-numeric: tabular-nums; }

/* Second menu inside a tab (Woningen > Kenmerken); a row on narrow screens */
.subnav-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
.subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; }
.subnav button { text-align: left; height: 38px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--fg-2); font-weight: 500; position: relative; transition: background 0.25s var(--ease), color 0.25s var(--ease); white-space: nowrap; }
.subnav button:hover { background: var(--zebra); color: var(--fg); }
.subnav button.active { background: var(--accent-soft); color: var(--fg); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sub-content { container-type: inline-size; min-width: 0; }
.sub-content.fade { animation: detail-fade 0.35s var(--ease); }
@container (max-width: 640px) {
  .subnav-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .subnav { flex-direction: row; overflow-x: auto; position: static; scrollbar-width: none; }
  .subnav::-webkit-scrollbar { display: none; }
  .subnav button { flex: none; }
}

/* Media */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { aspect-ratio: 4 / 3; max-width: 100%; border-radius: 6px; border: 1px solid var(--line); background: linear-gradient(135deg, var(--zebra), var(--line)); display: grid; place-items: center; color: var(--fg-3); position: relative; overflow: hidden; }
.tile .ic { width: 28px; height: 28px; opacity: 0.7; }
.tile span { position: absolute; left: 8px; bottom: 6px; font-size: 12px; color: var(--fg-2); }
.tile.add { border-style: dashed; border-color: var(--line-strong); background: var(--input-bg); cursor: pointer; transition: border-color 0.25s var(--ease), color 0.25s var(--ease); }
.tile.add:hover { border-color: var(--accent); color: var(--accent); }
.tile > a { position: absolute; inset: 0; display: grid; place-items: center; color: inherit; }
.tile.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.photo span, .tile.file span { right: 8px; padding: 2px 6px; border-radius: 4px; background: var(--panel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tile-remove { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--fg-2); display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity 0.2s var(--ease), color 0.2s var(--ease); }
.tile-remove .ic { width: 16px; height: 16px; opacity: 1; }
.tile:hover .tile-remove, .tile-remove:focus-visible, tr:hover .tile-remove { opacity: 1; }
.tile-remove:hover { color: var(--danger); }
td .tile-remove { position: static; opacity: 0.6; }
@media (hover: none) { .tile-remove { opacity: 1; } }
td.actions { width: 1%; }
[data-drop].dragging .tiles, [data-drop].dragging .drop { outline: 2px dashed var(--accent); outline-offset: 4px; }
.drop[data-add] { cursor: pointer; }
.drop { border: 1px dashed var(--line-strong); border-radius: 6px; background: var(--input-bg); padding: 20px; display: flex; align-items: center; gap: 14px; color: var(--fg-3); }
.drop .ic { width: 24px; height: 24px; }
.drop strong { color: var(--fg); display: block; font-weight: 600; }

/* Map (Project > Locatie) */
.map { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; height: 360px; background: var(--map-land); }
.map svg { width: 100%; height: 100%; display: block; }
.map-note { color: var(--fg-3); font-size: 13px; margin-top: 8px; }

/* ---------- Dashboards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 18px 20px; }
.kpi-label { font-size: 13.5px; color: var(--fg-2); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; line-height: 1.15; }
.kpi-value small { font-size: 15px; font-weight: 500; color: var(--fg-3); margin-left: 4px; }
.kpi-sub { font-size: 13px; color: var(--fg-3); margin-top: 4px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-col { display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { color: var(--fg-3); font-size: 13px; margin-top: 2px; }
.card-body { padding: 14px 20px 20px; }

.bar-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 2fr) 52px; gap: 14px; align-items: center; padding: 10px 8px; margin: 0 -8px; border: 0; background: none; width: calc(100% + 16px); text-align: left; border-radius: 6px; transition: background 0.25s var(--ease); }
button.bar-row:hover { background: var(--zebra); }
.bar-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-meta { display: block; color: var(--fg-3); font-size: 13px; }
.bar-track { height: 8px; background: var(--tab-base); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.bar-percent { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fg-2); }

.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--tab-base); gap: 2px; }
.stack span { display: block; height: 100%; }
.stack-sold { background: var(--fg-3); }
.stack-option { background: var(--warn); }
.stack-sale { background: var(--accent); }
.legend { display: grid; gap: 10px; margin-top: 16px; }
.legend-row { display: flex; align-items: center; gap: 10px; }
.legend-row .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-row .label { flex: 1; color: var(--fg-2); }
.legend-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }

.milestone { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.milestone:last-child { border-bottom: 0; padding-bottom: 0; }
.milestone:first-child { padding-top: 0; }
.milestone-date { flex: none; width: 50px; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: 4px 0; background: var(--input-bg); }
.milestone-day { display: block; font-weight: 700; font-size: 16px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.milestone-month { display: block; font-size: 11.5px; color: var(--fg-3); }
.milestone-text { min-width: 0; }
.milestone-title { display: block; font-weight: 600; }
.milestone-sub { display: block; font-size: 13px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Reports ---------- */
.report-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.report-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--fg-2); font-size: 13px; white-space: nowrap; }
.period { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.period button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--fg-2); font-weight: 500; font-size: 13px; transition: background 0.25s var(--ease), color 0.25s var(--ease); white-space: nowrap; }
.period button:hover { color: var(--fg); }
.period button.active { background: var(--input-bg); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 32, 0.12); }
.report-kpi { padding: 16px 18px; }
.report-kpi .kpi-label { display: flex; align-items: center; gap: 8px; }
.report-kpi .swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.report-kpi .kpi-value { margin-top: 6px; white-space: nowrap; }
.report-kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 4px; }
.report-kpi-foot .kpi-sub { margin-top: 0; min-width: 0; }
.report-kpi .spark { flex: none; width: 88px; height: 32px; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chart-card .card-head { align-items: flex-start; }
.report-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }

@media (max-width: 1099px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .report-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 24px; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .map { height: 260px; }
}
@media (max-width: 520px) {
  .report-kpi .spark { display: none; }
  .report-kpi .kpi-value { font-size: 22px; }
}

/* ---------- Marketing: the step bar and the info bar ----------
   <div class="page single with-infobar <name>">
       <div class="marketing-steps"></div>            marketing.renderSteps(): "Stap 2 van 4 — Merkfundament"
       <x-detail> ... </x-detail>                      tabs, fields and the actions in the footer
       <aside class="infobar"> <section class="info-card">...</section> </aside>   calm information, always visible
   </div>
   From 1100px the info bar is on the right; narrower it moves under the detail. */
.page.with-infobar { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto minmax(0, 1fr); gap: 16px 20px; }
.page.with-infobar > .marketing-steps { grid-column: 1 / -1; }
.page.with-infobar > .infobar { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

.marketing-steps { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 13.5px; color: var(--fg-2); }
.marketing-steps strong { color: var(--fg); font-weight: 600; }
.steps-bar { display: inline-flex; gap: 4px; }
.steps-bar span { width: 48px; height: 6px; border-radius: 3px; background: var(--tab-base); }
.steps-bar span.done { background: var(--accent); }
.steps-bar span.current:not(.done) { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.info-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; flex: none; }
.info-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.info-card p { color: var(--fg-2); font-size: 13.5px; }
.info-card .info-sub { color: var(--fg-3); font-size: 13px; margin-top: 8px; }
.progress { height: 8px; background: var(--tab-base); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.4s var(--ease); }
.info-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 2px; }
.info-list button { width: 100%; display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 0; border-radius: 6px; background: none; text-align: left; color: var(--fg-2); font-size: 13.5px; transition: background 0.2s var(--ease); }
.info-list button:hover { background: var(--zebra); }
.info-list button.active { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.info-list .count { margin-left: auto; color: var(--fg-3); font-size: 12.5px; font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.info-list .ic { margin-left: auto; width: 16px; height: 16px; color: var(--ok); stroke-width: 2.5; }
.info-steps { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--fg-2); font-size: 13.5px; }

@media (max-width: 1099px) {
  .page.with-infobar { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
  .page.with-infobar > .infobar { overflow: visible; }
}
@media (max-width: 767px) {
  .page.with-infobar > .marketing-steps { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .page.with-infobar > .infobar { padding: 16px; }
}
