/* Base styles: colours (same as Bouwplan, light and dark), reset, shell layout and shared elements. */
:root {
  --bg: #e8ebee;
  --panel: #f5f6f8;
  --input-bg: #ffffff;
  --zebra: #eef0f3;
  --line: #d6dbe0;
  --line-strong: #b4bcc5;
  --fg: #101820;
  --fg-2: #333e49;
  --fg-3: #56626e;
  --accent: #23784a;
  --accent-strong: #1a5e39;
  --accent-soft: #e2f1e8;
  --on-accent: #ffffff;
  --tab-base: #dde2e7;
  --tab-hover: #1f2b38;
  --ok: #23703f;
  --ok-soft: #e3f1e8;
  --warn: #8a5600;
  --warn-soft: #fbf0db;
  --danger: #b3261e;
  --danger-soft: #fbe7e5;
  --muted-soft: #e9ecef;
  --btn-dark: #3b4c5e;
  --btn-dark-hover: #2e3d4d;
  --map-land: #e4e8e3;
  --map-road: #ffffff;
  --map-park: #cfe3cf;
  --map-water: #c9dbe8;
  --map-block: #d5dad6;
  --nav-bg: #1f2b38;
  --nav-line: #2c3a48;
  --nav-fg: #d5dde5;
  --nav-dim: #aab6c2;
  --nav-strong: #ffffff;
  --nav-hover: #283746;
  --nav-active: #2d3e4f;
  --nav-accent: #7fd3a2;
  --c-blue: #3f6fb0;
  --c-amber: #b07a0e;
  --c-green: #23784a;
  --c-plum: #9a4f86;
  --c-other: #9aa4ae;
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 0.45s;
  --rail: 72px;
  --nav-w: 264px;
  --top-h: 56px;
  --radius: 6px;
}
/* Dark theme: app.applyTheme() always sets data-theme ("light" or "dark") in the <head>, so this is the only dark block. */
:root[data-theme="dark"] {
  --bg: #0f151b; --panel: #18212a; --input-bg: #121920; --zebra: #1b242d; --line: #2a3541; --line-strong: #3d4a58;
  --fg: #eef2f6; --fg-2: #c3ccd5; --fg-3: #9aa6b2; --accent: #5cc58a; --accent-strong: #7fd3a2; --accent-soft: #16301f;
  --on-accent: #08210f; --tab-base: #2a3541; --tab-hover: #9aa7b4; --ok: #6fca93; --ok-soft: #173020; --warn: #e6b05a;
  --warn-soft: #33281a; --danger: #ef6b62; --danger-soft: #3a1c1a; --muted-soft: #232d37; --btn-dark: #3a4a5b; --btn-dark-hover: #46586a;
  --map-land: #1c252d; --map-road: #2b3743; --map-park: #1d3326; --map-water: #1b2c3b; --map-block: #25303a;
  --nav-bg: #0b1117; --nav-line: #1c252e; --nav-fg: #d0d8e0; --nav-dim: #9aa7b4; --nav-strong: #ffffff; --nav-hover: #151e27; --nav-active: #1d2a37; --nav-accent: #7fd3a2; --c-blue: #5b8fd6; --c-amber: #b8812a; --c-green: #3faa6e; --c-plum: #b874a8; --c-other: #5d6b78;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shell: topbar on top, menu on the left, pages in #paging */
body { display: flex; flex-direction: column; overflow: hidden; }
.shell { flex: 1; min-height: 0; display: flex; }
#paging { flex: 1; min-width: 0; overflow-y: auto; }

/* Not logged in: no topbar and menu, the page (login) uses the whole screen */
body.logged-out x-topbar,
body.logged-out x-navigation { display: none; }

/* Pages */
.page { padding: 32px; animation: page-in 0.3s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } }
.page h1 { font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.page .lead { color: var(--fg-3); margin-bottom: 24px; }

/* Pages with a sidebar (x-sidebar) on the left: <div class="page <name> with-sidebar"><x-sidebar></x-sidebar><section class="content">...</section></div> */
.page.with-sidebar { height: 100%; display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 20px; padding: 20px 24px; }
.page.with-sidebar > .content { min-height: 0; overflow-y: auto; }

/* Icons from js/icons.js */
.ic { width: 20px; height: 20px; flex: none; }

/* Shared elements */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.button { height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--input-bg); font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background 0.25s var(--ease), border-color 0.25s var(--ease); }
.button:hover { background: var(--zebra); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.button.ghost { border-color: transparent; background: none; color: var(--fg-2); }
.button.ghost:hover { background: var(--zebra); color: var(--fg); }
.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--input-bg); transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.invalid { border-color: var(--danger); }
.field label { display: block; font-size: 14px; font-weight: 500; color: var(--fg); margin-bottom: 6px; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; }

/* ---------- Detail panels, fields, switches, tables (taken over from Bouwplan on 2026-10-27, used by x-detail) ---------- */
.tnum { font-variant-numeric: tabular-nums; }

/* A page may keep its x-modal inside the page element (so its page css applies); it must not become a grid cell. */
.page > x-modal { position: absolute; }

/* ---------- 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.danger-soft { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.button.danger-soft:hover { background: var(--danger-soft); filter: brightness(0.96); }
.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); }

/* ---------- 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-note { color: var(--fg-3); font-size: 12.5px; line-height: 1.45; margin-top: 4px; }
.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: 120px; padding: 12px 14px; line-height: 1.6; 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");
}
input[type="color"].input { padding: 4px; width: 72px; cursor: pointer; }

.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; }
/* base.css makes every label in a .field a block with a bold text; switches and checks are labels too */
.field label.switch { display: inline-flex; margin-bottom: 0; }
.field label.check { display: flex; margin-bottom: 0; font-weight: 400; 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 td.wrap { white-space: normal; }
.table .switch { min-height: 0; }

.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); }
.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; }

.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; }

/* ---------- Small marks ---------- */
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; vertical-align: middle; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12.5px; font-weight: 500; background: var(--muted-soft); color: var(--fg-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 1099px) {
  .page.with-sidebar { gap: 16px; padding: 16px; }
}

@media (max-width: 767px) {
  .page { padding: 20px 16px; }
  .page.with-sidebar { display: block; height: auto; padding: 0; }
  .page.with-sidebar > .content { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Mobile: the title of the page is in the topbar (x-topbar), so the h1 of the page is not shown */
@media (max-width: 767px) {
  .page h1 { display: none; }
}
