/* Shared by every page: tokens, header and nav, form controls, tables, pager. */
:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1d1f1c; --muted: #6b6f68;
  --line: #e3e4e0; --accent: #2f6b3a; --accent-soft: #e7f0e8; --hover: #f1f2ee;
  --accent-hover: #285c32;   /* hover on accent-filled controls; white on it ≈ 7.9:1 */
  --danger: #a3372b; --danger-soft: #f6e6e3; --danger-hover: #8a2e24; --warn: #8a5a00; --warn-soft: #f6eedb;
  --on-accent: #ffffff; --on-danger: #ffffff; --control-border: #858a80;
  --map-area: #c0392b;       /* a notification's felling area on the maps */
  --map-teatis: #a64ca6;     /* the register's WMS line colours, for the map key: notifications, */
  --map-eraldis: #0073e5;    /* stands (private forest), */
  --map-eraldis-riik: #0000ff; /* stands (state, municipal and public-law forest), */
  --map-kataster: #ffff00;   /* cadastral units */
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --print-line: #bbb;                          /* card and table borders on paper */
  --shadow-pop: 0 6px 20px rgb(0 0 0 / .12);   /* popups: option lists, chart tips, the colour picker */
  /* Chart slots (turg.html, tegevus.html): the validated categorical order of
     the dataviz reference palette; slots 1-4 pass every adjacent check on
     light, aqua and yellow are below 3:1 on the surface, so every chart has a
     table view. */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-na: #b4b8b1;      /* "not known yet": neutral, not a category */
  /* One content column on every page, the header and footer aligned with it
     (body.page-wide lifts the cap). */
  --page-max: 1280px; --gutter: 24px;
  --focus-top: 0px; --focus-bottom: 0px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 14px/1.45 var(--font); }
header, main, footer { max-width: var(--page-max); margin-left: auto; margin-right: auto; }
body.page-wide :is(header, main, footer) { max-width: none; }
header { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; padding: 18px var(--gutter) 10px; }
h1 { font-size: 20px; margin: 0; font-weight: 650; }
.sync { color: var(--muted); font-size: 13px; }
footer { padding: 12px var(--gutter) 24px; border-top: 1px solid var(--line); margin-top: 16px; }
nav { display: flex; gap: 14px; font-size: 14px; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--text); }
/* The current item: an accent bar under it that a hover never imitates (an
   underline, so the header keeps its height). */
nav a.here { color: var(--text); font-weight: 600;
             text-decoration: underline 2px var(--accent); text-underline-offset: 6px; }
nav .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px;
             background: var(--danger); color: var(--on-accent); font-size: 11px; font-weight: 700;
             text-align: center; line-height: 17px; }
main { padding: 0 var(--gutter) 32px; }
/* The list loader must reserve the viewport before its rows arrive, so the
   footer does not start visible and then jump below the table. */
main.list-shell { min-height: 100vh; }
.list-shell .segments { min-height: calc(1.45em + 12px); }
/* The account group on the right of the header (common.js renderNav): the
   admin links, then the login and Log out with the language switch, which
   wrap as one unit and stay together. */
.acct { margin-left: auto; display: flex; align-items: center; justify-content: flex-end;
        gap: 6px 14px; flex-wrap: wrap; align-self: center; }
.acct .me { display: flex; align-items: center; justify-content: flex-end; gap: 6px 14px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 13px; }
.who .logout { margin-left: 6px; font: inherit; color: var(--accent); background: none; border: 0; padding: 2px 4px;
               border-radius: 4px; cursor: pointer; }
.who .logout:hover:not(:disabled) { background: var(--hover); }
.who .account { margin-left: 6px; }
.who .account[aria-current] { color: var(--text); font-weight: 600; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lang button { font: inherit; font-size: 12px; font-weight: 600; letter-spacing: .02em; border: 0; background: var(--panel);
               color: var(--muted); padding: 4px 9px; cursor: pointer; }
.lang button + button { border-left: 1px solid var(--line); }
.lang button.on { background: var(--accent); color: var(--on-accent); }
/* The public pages' header (kutse.html, valja.html: no nav, the switch on its
   own) and their sign-in link; its hover and pressed states are with the
   other controls' below. */
header > .lang { margin-left: auto; align-self: center; }
a.signin { display: inline-block; text-decoration: none; padding: 7px 14px; border-radius: 6px;
           background: var(--accent); color: var(--on-accent); }
a { color: var(--accent); }
/* A QR code drawn as SVG rects (kutse.js): black on white in any theme or
   forced-colours mode, so a phone's camera reads it. */
svg.qr { display: block; width: 100%; height: auto; aspect-ratio: 1; forced-color-adjust: none; }
svg.qr .qr-bg { fill: #fff; }
svg.qr .qr-on { fill: #000; }

/* Count filters: pills that pick several (the list pages). */
.segments { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 12px; }
.segments button { border: 1px solid var(--line); background: var(--panel); color: var(--text);
                   border-radius: 999px; padding: 5px 12px; cursor: pointer; font: inherit; }
.segments button .n { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.segments button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.segments button.on .n { color: inherit; }
/* Pick one of N views (a measure, a period, which prices): one joined group.
   .toggle.lg for a page-level switch. */
.toggle { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.toggle button { font: inherit; font-size: 12px; border: 0; background: var(--bg); color: var(--muted);
                 padding: 5px 10px; cursor: pointer; }
.toggle button + button { border-left: 1px solid var(--line); }
.toggle button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.toggle.lg button { font-size: 14px; padding: 6px 12px; }
/* Long page-level labels stack on a phone instead of wrapping into two boxes. */
@media (max-width: 640px) {
  .toggle.lg { display: flex; flex-direction: column; }
  .toggle.lg button { text-align: left; }
  .toggle.lg button + button { border-left: 0; border-top: 1px solid var(--line); }
}

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
           gap: 10px 14px; background: var(--panel); border: 1px solid var(--line);
           border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.filters label, .filters .field-group { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
/* A filter's reason (a bad number, a reversed range), under the grid. */
.filters .reason { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--danger); }
.filters .reason:empty { display: none; }
/* The filter form's "Clear filters" box, bottom right of its grid cell
   (<div class="actions">; a div only: alerts' button.act.actions is a button
   in a flex form). */
.filters > div.actions { display: flex; align-items: flex-end; justify-content: flex-end; }
/* "More filters" (common.js filtersToggle): only on narrow screens. */
.filters-more { display: none; }

/* Fields: one size everywhere (14 px, 32 px high); the filter panel is the one
   compact exception. A caption sits above its field, 12 px muted. */
input, select, textarea { font: inherit; font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg);
                          border: 1px solid var(--control-border); border-radius: 6px; padding: 5px 7px; }
.filters :is(input, select, textarea) { font-size: 12px; }
:where(.field, .addowner label, .upload label, .form label, .adjust label, .cform label, .seller label,
       .edit label, .edit .field, .reg label, .invite label, .notes form label):not(:has(> input[type=checkbox]), [hidden]) {
  display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
/* Disabled fields look unavailable: no field background, muted text, a dashed border. */
:is(input:not([type=checkbox], [type=radio]), select, textarea):disabled {
  background: var(--hover); color: var(--muted); border-color: var(--line); border-style: dashed;
  cursor: not-allowed; opacity: 1; }
/* Required / optional marks in a label: <span class="req">Name</span> gets a
   star when its field is required (CSS only: fieldName() never reads it);
   <span class="opt">(optional)</span> for the odd optional one. */
label:has(> :is(input, select, textarea):required) > .req::after { content: " *"; content: " *" / ""; color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; }

button.act { font: inherit; padding: 5px 10px; border-radius: 6px; cursor: pointer;
             border: 1px solid var(--line); background: var(--bg); color: var(--text); }
button.act:hover:not(:disabled) { background: var(--hover); }
button.act.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.act.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
button.act.danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
/* A button that reads as a link (inside a sentence, a table cell, a bar). */
button.link { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--accent);
              text-decoration: underline; cursor: pointer; }
button.link:hover:not(:disabled) { color: var(--accent-hover); text-decoration-thickness: 2px; }
button.link:disabled { color: var(--muted); cursor: default; }
/* A row of controls: buttons, a field, their status line. div only: tr.row is
   a clickable table row, form.filters.row the charts' filter bar. */
div.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.bar { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px;
       color: var(--muted); font-size: 13px; gap: 8px; flex-wrap: wrap; }
/* The same pager again under a long list (common.js wireBottomPager). */
.bar.bottom { justify-content: flex-end; margin: 8px 0 0; }
.pager button { font: inherit; border: 1px solid var(--line); background: var(--panel);
                color: var(--text); border-radius: 6px; padding: 4px 10px; cursor: pointer; }

/* Hover and pressed feedback on every clickable control: the hover background
   on neutral ones, a darker accent on accent-filled ones. */
button.act.primary:hover:not(:disabled), .segments button.on:hover:not(:disabled),
.lang button.on:hover:not(:disabled), a.signin:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.segments button:not(.on):hover:not(:disabled), .pager button:hover:not(:disabled),
.toggle button:not(.on):hover:not(:disabled), .lang button:not(.on):hover:not(:disabled) { background: var(--hover); }
.toggle button.on:hover:not(:disabled) { color: var(--accent-hover); }
main summary:hover { text-decoration: underline; }
:is(button.act, .segments button, .pager button, .toggle button, .lang button):active:not(:disabled),
a.signin:active { transform: translateY(1px); }
/* One disabled look for every button: dimmed, default cursor, no hover. */
button:disabled, button[aria-disabled="true"] { opacity: .45; cursor: default !important; }
/* One focus ring, in the product's colour. */
:where(a[href], button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
:where(th[data-sort] button, td a, td button, td input, td select):focus-visible { outline-offset: 0; }

/* Tables scroll inside their box, never the page. A shadow shows on the side
   that has hidden columns (the `local` covers hide it at either end). */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px;
             background:
               linear-gradient(to right, var(--panel) 30%, rgb(255 255 255 / 0)) left / 28px 100% no-repeat local,
               linear-gradient(to left, var(--panel) 30%, rgb(255 255 255 / 0)) right / 28px 100% no-repeat local,
               radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / .16), transparent) left / 12px 100% no-repeat scroll,
               radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / .16), transparent) right / 12px 100% no-repeat scroll,
               var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* Headers may wrap (the longer ET labels), so a list fits the 1280 px page (F-06-12). */
th { white-space: normal; min-width: 4ch; }
td.wrap { white-space: normal; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); user-select: none;
     position: sticky; top: 0; background: var(--panel); }
th[data-sort] { cursor: pointer; }
th.sorted { color: var(--text); }
/* Sortable headers carry a faint ↕ until sorted (common.js headCells). */
th[data-sort] .sortmark { opacity: .35; }
th.sorted .sortmark { opacity: 1; }
th[data-sort] button:hover { color: var(--text); text-decoration: underline; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.date { font-variant-numeric: tabular-nums; }
/* Opt-in (<div class="tablewrap wrap-head">): a list whose headers wrap at
   the bottom, two lines at most, so a column is as wide as its values; the
   sort mark stays beside the last word. */
.tablewrap.wrap-head thead th { white-space: normal; vertical-align: bottom; }
.tablewrap.wrap-head thead th button { display: inline-flex; align-items: last baseline; gap: .2em; }
/* A long free-text value (a name, a joined list): cut with an ellipsis, the
   full value in the cell's title. --clip sets another width. */
td.clip { max-width: var(--clip, 22ch); overflow: hidden; text-overflow: ellipsis; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: var(--hover); }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
/* Narrow screens: the first column (a row's identity) stays while the rest
   scrolls; .lead2 on the .tablewrap keeps the first two (a checkbox first). */
@media screen and (max-width: 760px) {
  .tablewrap :is(th, td):first-child { position: sticky; left: 0; z-index: 1; background: var(--panel);
                                       box-shadow: 1px 0 0 var(--line); }
  .tablewrap th:first-child { z-index: 2; }
  .tablewrap.lead2 :is(th, td):nth-child(2) { position: sticky; left: var(--lead1, 40px); z-index: 1;
                                              background: var(--panel); box-shadow: 1px 0 0 var(--line); }
  .tablewrap.lead2 :is(th, td):first-child { box-shadow: none; }
  .tablewrap :is(tr.row, tr.grp):hover > td:first-child,
  .tablewrap.lead2 :is(tr.row, tr.grp):hover > td:nth-child(2) { background: var(--hover); }
  .tablewrap.tablewrap :is(tr.open, tr.on) > td:first-child,   /* doubled: wins over the hover rule */
  .tablewrap.lead2.lead2 :is(tr.open, tr.on) > td:nth-child(2) { background: var(--accent-soft); }
  .tablewrap tr.bad > td:first-child, .tablewrap.lead2 tr.bad > td:nth-child(2) { background: var(--danger-soft); }
  .tablewrap tr.detail > td:first-child { position: static; background: var(--bg); box-shadow: none; }
}

.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px;
       background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tag.weak { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
/* A notification whose owner was called (common.js calledClass / calledTag):
   red for every login, in the notification table and the dossiers; green
   while the latest mark says the call was successful, amber while it says
   "call again", grey while it says "not interested". An open or hovered table
   row keeps its own colour. */
.tablewrap tr.called:not(.open, .row:hover, .grp:hover) > td { background: var(--danger-soft); }
.tablewrap tr.called > td:first-child { box-shadow: inset 4px 0 0 var(--danger), 1px 0 0 var(--line); }
.tablewrap tr.called.call-success:not(.open, .row:hover, .grp:hover) > td { background: var(--accent-soft); }
.tablewrap tr.called.call-success > td:first-child { box-shadow: inset 4px 0 0 var(--accent), 1px 0 0 var(--line); }
.tablewrap tr.called.call-again:not(.open, .row:hover, .grp:hover) > td { background: var(--warn-soft); }
.tablewrap tr.called.call-again > td:first-child { box-shadow: inset 4px 0 0 var(--warn), 1px 0 0 var(--line); }
.tablewrap tr.called.call-uninterested:not(.open, .row:hover, .grp:hover) > td { background: var(--line); }
.tablewrap tr.called.call-uninterested > td:first-child { box-shadow: inset 4px 0 0 var(--muted), 1px 0 0 var(--line); }
.called-tag { margin-left: 6px; background: var(--danger); color: var(--on-danger); white-space: nowrap;
              max-width: 16ch; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.called-tag.marked { background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
/* How the latest call went (common.js outcomeTag): after the called tag, and
   in a notification's list of marks. */
.outcome-tag { margin-left: 4px; white-space: nowrap; vertical-align: bottom; }
.outcome-tag.success { background: var(--accent); color: var(--on-accent); }
.outcome-tag.failed, .outcome-tag.no_number { background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.outcome-tag.call_again { background: var(--warn); color: var(--on-danger); }
.outcome-tag.not_interested { background: var(--muted); color: var(--on-accent); }
/* A warning box above or below a result (a computation's hoiatused, a file's notes).
   div only: <span class="tag warn"> and <li class="warn"> keep their own boxes. */
div.warn { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
/* Owner colour marks: a dot, empty (dashed ring) when no colour is set. */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px;
       background: var(--c, transparent); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .2); }
.dot.none { box-shadow: none; border: 1px dashed var(--muted); opacity: .6; }
[data-c="punane"] { --c: #d64545; }
[data-c="oranz"] { --c: #e8833a; }
[data-c="kollane"] { --c: #e6b800; }
[data-c="roheline"] { --c: #3f9a4f; }
[data-c="sinine"] { --c: #3b7dd8; }
[data-c="lilla"] { --c: #8e5bd0; }
.swatches { display: flex; gap: 4px; align-items: center; }
.swatches button { border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px;
                   cursor: pointer; line-height: 0; }
.swatches button:hover:not(:disabled) { background: var(--hover); }
.swatches button.on { border-color: var(--text); }
.swatches .dot { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.removed { color: var(--danger); font-size: 12px; margin-left: 6px; }
/* Empty and failed states (common.js emptyState / emptyRow / loadFailed). */
.empty { padding: 40px; text-align: center; color: var(--muted); white-space: normal; }
.empty p { margin: 0 0 8px; }
.empty p:last-child { margin-bottom: 0; }
.empty.state { background: var(--panel); border-radius: 10px; }
:not(td) > .empty.state { border: 1px solid var(--line); }
td > .empty.state { padding: 32px 16px; }
.empty.failed { color: var(--text); border: 1px solid var(--danger); background: var(--danger-soft); border-radius: 10px; }
.empty.failed b { color: var(--danger); }
td > .empty.failed { margin: 8px; padding: 24px 16px; }
/* A reload in progress: the rows, tiles and panels already shown stay, dimmed,
   until the new ones arrive (the filters above them do not dim), and the count
   line carries an ellipsis while it is stale. */
.loading tbody, #list.loading, main.loading .tiles, main.loading .panel, main.loading section {
  opacity: .5; transition: opacity .15s; }
.bar [aria-busy="true"]::after { content: " …"; }

/* Inline feedback after an action (common.js sayDone / sayFailed): neutral in
   muted 13 px, a success in the accent colour with "✓ ", a failure in red. */
.msg { font-size: 13px; color: var(--muted); }
.msg.ok { color: var(--accent); }
.msg.err, .err, .fail { font-size: 13px; color: var(--danger); }
.fail { margin-left: 8px; }
p.err { margin: 0 0 8px; }
/* Empty lines take no room, except live regions, which must stay rendered. */
:is(.msg, .err, .fail):empty:not([aria-live], [role]) { display: none; }
:is(.msg, .err, .fail):empty { margin: 0; }

/* Confirmations (common.js ask()). */
dialog.ask { border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; width: 460px;
             max-width: calc(100vw - 32px); background: var(--panel); color: var(--text);
             box-shadow: 0 10px 30px rgb(0 0 0 / .18); }
dialog.ask::backdrop { background: rgb(0 0 0 / .25); }
dialog.ask h3 { margin: 0 0 6px; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
dialog.ask p { margin: 0 0 12px; color: var(--muted); overflow-wrap: anywhere; }
dialog.ask p.item { color: var(--text); border-left: 3px solid var(--line); padding-left: 10px;
                    white-space: pre-wrap; max-height: 8em; overflow: auto; }
dialog.ask .askinput { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
dialog.ask textarea { width: 100%; resize: vertical; }
dialog.ask .row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Elements given display above still hide with the hidden attribute. */
:is(.bar, .acct, .toggle, .filters-more, .tileline, .empty, .field-group, dialog.ask p, dialog.ask .askinput)[hidden] { display: none; }

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  header { padding: 14px var(--gutter) 8px; }
  main { padding: 0 var(--gutter) 24px; }
  .acct { margin-left: 0; width: 100%; }
  .acct > nav.right { margin-right: auto; }
  .filters { grid-template-columns: 1fr; }
  /* Below 640 px only the first field (the search) and the actions show
     until "More filters" opens the rest; a form without that button
     (kinnistud, tegevus) is never folded. */
  .filters-more { display: block; justify-self: start; }
  .filters:has(> .filters-more):not(.open) > :not(:first-child, .filters-more, .actions, .reason) { display: none; }
  .segments { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .segments button { flex: none; }
  .list-shell .segments { min-height: calc(1.45em + 16px); }
}

/* Paper: the record without the screen's controls, every column, rows and
   cards kept whole. Pages add only what is their own. */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  header, main, footer { max-width: none; }
  main.list-shell { min-height: 0; }
  header nav, header .acct, header .sync, footer, .noprint,
  .segments, .toggle, .filters, .pager, .bar.bottom, .dossier-pager, .add, .addowner, .swatches,
  dialog.ask, main :not(td, th) > button, main textarea, .chat, .chat-toggle { display: none !important; }
  header { padding: 0 0 6px; }
  main { padding: 0; }
  .tablewrap { overflow: visible; border-color: var(--print-line); background: none; }
  th, td { white-space: normal; padding: 3px 5px; }
  th { position: static; }
  td.date, td.num { white-space: nowrap; }
  td.clip { max-width: none; overflow: visible; }
  tr, .card, .stat { break-inside: avoid; }
  section > h3, .title { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
  th[data-sort] .sortmark { display: none; }
  td :is(select, input, textarea), td :is(select, input, textarea):disabled {
    appearance: none; border: 0; background: none; padding: 0; width: auto; max-width: none; color: inherit; }
  /* The dossiers' own forms (status, colour, contacts, notes, reminders). */
  .card :is(select, input:not([type=checkbox], [type=radio], [type=hidden])):not(td *, th *) { display: none; }
  .card label:has(> :is(select, input:not([type=checkbox], [type=radio]))):not(td *, th *) { display: none; }
  .card h4:has(+ .items:empty), .items:empty { display: none; }
}

/* Dossiers, forms and admin pages: the title line, cards, sections. */
.title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.title h2 { font-size: 22px; margin: 0; font-weight: 650; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.card h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.card dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
/* Small lists inside a dossier card (added contacts, reminders), with a delete
   button and an add form under them. */
.card h4 { font-size: 12px; margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--line);
           color: var(--muted); font-weight: 600; }
.items { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.items li { display: flex; gap: 8px; align-items: baseline; }
.items li > :first-child { flex: none; }
.items .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.items li > .what { flex: 1 1 auto; }   /* also when it is the only column */
.items .k { color: var(--muted); min-width: 92px; }
.items .when { font-variant-numeric: tabular-nums; }
.x { font: inherit; font-size: 12px; border: 1px solid transparent; background: none; color: var(--muted);
     border-radius: 5px; padding: 0 6px; cursor: pointer; flex: none; }
.x:hover:not(:disabled) { border-color: var(--line); color: var(--danger); }
.add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.add input:not([type=datetime-local]) { flex: 1 1 140px; min-width: 0; }
.add select, .add input[type=datetime-local] { flex: none; }
.add .reason { flex-basis: 100%; font-size: 13px; color: var(--danger); }
.add .reason:empty { display: none; }
/* A mini form whose fields carry visible captions: <label class="mini">When
   <input …></label>; .grow takes the free width. */
.add:has(> label.mini) { align-items: flex-end; }
.add label.mini { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); flex: none; }
.add label.mini.grow { flex: 1 1 160px; min-width: 0; }
.add label.mini > :is(input, select, textarea) { flex: none; width: 100%; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }

/* Charts (turg.html, tegevus.html; common.js svgEl, niceTicks, columnPath,
   chartTooltip): a panel per chart, the SVG, its tooltip and the table view
   under it. Slot colours are the --series-N tokens. */
.filters.row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 10px; margin-bottom: 14px; }
.panel-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; margin-bottom: 6px; }
.panel-head h3 { font-size: 15px; font-weight: 650; margin: 0; flex: 1; min-width: 200px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit:focus { fill: rgb(0 0 0 / .04); outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 2px; }   /* the one focus ring (F-06-42, F-06-80) */
.tip { position: absolute; pointer-events: auto; background: var(--panel); border: 1px solid var(--line);
       border-radius: 8px; box-shadow: var(--shadow-pop); padding: 8px 12px; font-size: 12px;
       max-width: 100%; box-sizing: border-box; overflow-wrap: anywhere; z-index: 5; }
.tip .t { color: var(--muted); margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 6px; }
.tip .r b { font-variant-numeric: tabular-nums; }
.tip .k { display: inline-block; width: 12px; height: 2px; border-radius: 1px; }
/* A legend's colour key (turg.js): the slot as a class, not a style
   attribute, since the CSP allows no inline style. */
.swatch[data-slot="1"] { background: var(--series-1); }
.swatch[data-slot="2"] { background: var(--series-2); }
.swatch[data-slot="3"] { background: var(--series-3); }
.swatch[data-slot="4"] { background: var(--series-4); }
.swatch[data-slot="na"] { background: var(--series-na); }
details.tableview summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 6px; }
details.tableview .tablewrap { margin-top: 6px; max-height: 360px; overflow: auto; }
section { margin: 18px 0; }
section > h3 { margin: 0 0 6px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
/* One section-heading style (also the offers page's "History"). */
section > h3, h3.history { font-size: 15px; font-weight: 650; }
:is(section > h3, h3.history) .n { color: var(--muted); font-weight: 500; font-size: 13px; }
section > .note { color: var(--muted); font-size: 13px; margin: -2px 0 6px; }
.changes li { margin: 2px 0; }
.changes { margin: 0; padding-left: 18px; }

/* An upload form stacked as a card (<form class="card upload stacked">: the
   file, its fields, the check button; hinnad, nimekirjad). The offer page's
   own .upload is a row and does not take .stacked. */
.upload.stacked { display: grid; gap: 10px; max-width: 760px; }
.upload.stacked .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 14px; }

/* "Add owner" form (common.js addOwnerForm). */
.addowner { margin-top: 8px; }
.addowner summary { cursor: pointer; color: var(--accent); width: max-content; }
.addowner form { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 12px;
                 margin-top: 8px; max-width: 760px; }
.addowner label.suggest { position: relative; }
.addowner .suggest .opts { right: auto; min-width: 100%; width: max-content; max-width: min(380px, 90vw); }
.addowner label.wide { grid-column: 1 / -1; }
.addowner .row { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.addowner .note { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); }

/* Multi-value picker (common.js makePicker): chips plus a type-ahead list. */
.combo { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
         background: var(--bg); border: 1px solid var(--control-border); border-radius: 6px; padding: 3px 5px; }
.combo input { border: 0; background: none; padding: 2px; outline: none; flex: 1; min-width: 90px; }
/* The metsakorraldaja picker with its "Only these" / "All but these" select. */
.kpick { display: flex; gap: 6px; align-items: flex-start; }
.kpick .combo { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600;
        background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 3px 1px 9px; }
.chip button { font: inherit; line-height: 1; border: 0; padding: 0 4px; background: none;
               color: inherit; cursor: pointer; }
.opts { position: absolute; z-index: 5; top: calc(100% + 3px); left: 0; right: 0; margin: 0;
        padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line);
        border-radius: 8px; box-shadow: var(--shadow-pop); max-height: 300px; overflow: auto; }
.opts li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 8px;
           border-radius: 5px; cursor: pointer; white-space: nowrap; }
.opts li.on { background: var(--hover); }
.opts li .m { color: var(--muted); font-size: 12px; }

/* Checking and calculating, shared by the forms (common.js fieldProblem/markFields):
   a field whose value cannot be used is red, its reason shown next to the form;
   while a result is recalculated the old numbers stay, dimmed, beside a spinner. */
input.invalid, select.invalid, textarea.invalid { border-color: var(--danger) !important; background: var(--danger-soft) !important; }
.busy-dim { opacity: .5; transition: opacity .15s; }
.spinner { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -2px;
           border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
           animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.calc { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
        margin: 8px 0; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
        background: var(--panel); font-size: 13px; }
.calc[hidden] { display: none; }
.calc.ok { color: var(--muted); }
.calc.err { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
           margin: 12px -14px -12px; padding: 10px 14px; border-top: 1px solid var(--line);
           background: var(--panel); border-radius: 0 0 10px 10px; }
/* Unsaved changes, said beside a save button (the save bar, a dossier's edit form). */
.msg.dirty { color: var(--warn); }
td.sum { font-variant-numeric: tabular-nums; color: var(--muted); }
td.sum.bad { color: var(--danger); font-weight: 600; }

/* The map pages: a short line per source above the map when its tiles stop
   arriving (common.js watchTiles); the box in place of a map without Leaflet. */
.tileline { display: block; }
#map .empty { padding: 24px; }

/* The visual input boundary is separate from decorative card/table dividers. */
.combo:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.filters .field-group > label { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
           overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
th[data-sort] button { font: inherit; color: inherit; border: 0; background: none; padding: 0;
                       min-height: 24px; min-width: 24px; cursor: pointer; text-align: inherit; }
html { scroll-padding-block-start: var(--focus-top); scroll-padding-block-end: var(--focus-bottom); }

/* The chat (chat.js): a button and a panel at the bottom right of every page
   with the nav. The panel's width and height are the user's (set from the
   script when resized, kept in the browser); on a narrow screen it is a sheet
   across the bottom. The page keeps room under its last line for the button. */
body.has-chat { padding-bottom: 64px; }
.chat-toggle { position: fixed; right: 16px; bottom: 16px; z-index: 40; display: inline-flex; align-items: center;
               gap: 6px; padding: 9px 16px; border: 0; border-radius: 999px; background: var(--accent);
               color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-pop); }
.chat-toggle:hover { background: var(--accent-hover); }
.chat-toggle[hidden], .chat[hidden], .chat-older[hidden] { display: none; }
.chat-toggle .badge, .chat-list .badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px;
               background: var(--danger); color: var(--on-danger); font-size: 11px; font-weight: 700;
               text-align: center; line-height: 17px; }
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 420px; height: 520px;
        min-width: 300px; min-height: 320px; max-width: calc(100vw - 32px); max-height: calc(100vh - 32px);
        display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
        border-radius: 10px; box-shadow: var(--shadow-pop); overflow: hidden; }
.chat-grip { position: absolute; left: 0; top: 0; z-index: 1; width: 22px; height: 22px; padding: 0; border: 0;
             cursor: nwse-resize; background: none; }
.chat-grip::before { content: ""; position: absolute; left: 5px; top: 5px; width: 9px; height: 9px;
                     border-left: 2px solid var(--muted); border-top: 2px solid var(--muted); }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
             padding: 8px 10px 8px 28px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 15px; }
.chat-close { padding: 0 6px; border: 0; background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.chat-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(110px, 32%) 1fr; }
/* A nav, so not the header's wrapping row (nav above): one column, top down. */
.chat-list { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 0; font-size: inherit;
             overflow-y: auto; padding: 6px 0; border-right: 1px solid var(--line); }
.chat-list button { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
                    padding: 6px 10px; border: 0; background: none; color: var(--text); font: inherit;
                    text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.chat-list button:hover { background: var(--hover); }
.chat-list button.on { background: var(--accent-soft); font-weight: 600; }
.chat-sub { margin: 10px 10px 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-title { margin: 0; padding: 6px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.chat-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px; }
.chat-older { display: block; margin: 0 auto 8px; font-size: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chat-log li { align-self: flex-start; max-width: 88%; padding: 4px 8px; border: 1px solid var(--line);
               border-radius: 8px; background: var(--bg); }
.chat-log li.mine { align-self: flex-end; background: var(--accent-soft); }
.chat-log li.chat-empty { align-self: center; border: 0; background: none; color: var(--muted); }
.chat-log p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.chat-meta span { font-weight: 600; color: var(--text); }
.chat-del { margin-left: auto; padding: 0 2px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-width: 0; min-height: 40px; resize: none; font: inherit; }
.chat-status { margin: 0 8px 6px; font-size: 12px; }
.chat-status:empty { display: none; }
@media (max-width: 600px) {
  .chat { left: 8px; right: 8px; bottom: 8px; width: auto !important; height: 75vh !important; max-width: none; }
  .chat-grip { display: none; }
  .chat-head { padding-left: 12px; }
  .chat-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .chat-list { flex-direction: row; gap: 4px; overflow-x: auto; padding: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-list button { width: auto; white-space: nowrap; }
  .chat-sub { display: none; }
}
:where(a[href], button, input, select, textarea, [tabindex]) {
  scroll-margin-block-start: var(--focus-top); scroll-margin-block-end: var(--focus-bottom);
}
