/* ── kit.css — DS primitives, stable class names ──────────────────────────────
   Ported from MANYMIO ds v0.2's admin kit; see docs/design/manymio-ds-v0.2.md
   section 3 for the anatomy and section 4 for the laws.

   Composes tokens.css only. A world stylesheet (admin, site, marketing) adds
   what is unique to it and never restates a rule from here: a duplicate loading
   after this file would silently override it.

   NB: never write a class glob ending in a star immediately before a slash in a
   comment in this file. That sequence closes the comment early and the CSS
   parser then swallows the next rule whole.
   ────────────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

html, body {
  background: var(--app-page);
  color: var(--a-body);
  font: 400 var(--fs-body) / var(--lh-body) var(--f-body);
  letter-spacing: var(--ls-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--a-ink);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
}
p { margin: 0; }
/* --accent-ink, not --accent: the accent as TEXT. The two are the same colour
   on the platform's own palette and separate roles on a theme's, where a brand
   colour bright enough to be a button fill is usually below AA as a link. Same
   substitution on .tab.on, .pgn b.on and .mi.on below — see tokens.css's
   coastal-amber block for the enumeration of both accent directions. */
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.mono { font-family: var(--f-mono); }
.tnum { font-variant-numeric: tabular-nums; }
.body-strong { color: var(--a-ink); font-weight: 500; }
.muted { color: var(--a-muted); }

/* Screen-reader-only text. Never display:none — that removes it from the
   accessibility tree too. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Keyboard users must always be able to see where they are. Dark worlds
   override the colour only; the geometry is shared. */
:focus-visible {
  outline: 2px solid rgb(var(--rgb-focus-ring) / 0.55);
  outline-offset: 2px;
}

/* The brand glyph from templates/_mark.html. An SVG with no intrinsic size
   fills its container, so it gets a default here and each world scales it up.
   The counter is cut in --app-surface by default; the dark worlds restate the
   stroke because they sit it on a dark chrome. */
.brand-mark { width: 26px; height: 26px; flex: none; }
.brand-mark path { stroke: var(--app-surface); }

/* ── Buttons — capsule law ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--h-ctl-md);
  padding: 0 var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--r-ctl);
  font: 500 13.5px/1 var(--f-body);
  letter-spacing: var(--ls-ui);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-ctl) var(--ease-brand),
              border-color var(--t-ctl) var(--ease-brand),
              color var(--t-ctl) var(--ease-brand);
}
.btn:hover { text-decoration: none; }
.btn.sm { height: var(--h-ctl-sm); padding: 0 var(--sp-3); font-size: var(--fs-small); }
.btn.lg { height: var(--h-ctl-lg); padding: 0 26px; font-size: 14.5px; }
.btn.pri { background: var(--accent); color: var(--on-accent-fill); }
.btn.pri:hover { background: var(--accent-hover); }
.btn.sec { background: var(--app-surface); color: var(--a-ink); border-color: var(--line-lt-2); }
.btn.sec:hover { background: var(--app-surface-2); border-color: var(--line-lt-3); }
.btn.ghost { background: transparent; color: var(--a-body); }
.btn.ghost:hover { background: var(--app-surface-2); }
.btn.danger { background: var(--err); color: var(--on-accent); }
.btn.dis { opacity: 0.45; pointer-events: none; }
.icon-btn { width: var(--h-ctl-md); padding: 0; }
.icon-btn.sm { width: var(--h-ctl-sm); }
.w-full { width: 100%; }

/* ── Fields ───────────────────────────────────────────────────────────────────
   The mono uppercase label is the single most identity-carrying detail in the
   system. Keep it.

   Django renders its own widgets, so a control is not always wrapped in .inp.
   The bare element selectors below give an unwrapped widget the same anatomy;
   they are an addition to the DS kit, not a deviation from it.
   ────────────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.lbl,
.field > span:first-child:not(.lbl-row) {
  font-family: var(--f-mono);
  font-size: var(--fs-tlabel);
  letter-spacing: var(--ls-mono-1);
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--a-muted);
}
.lbl-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.lbl-row a { font-size: 12px; line-height: 1.2; }

.inp,
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="tel"], input[type="number"], input[type="search"], input[type="date"],
select, textarea {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  height: var(--h-ctl-md);
  padding: 0 var(--sp-4);
  background: var(--app-surface);
  border: 1px solid var(--line-lt-2);
  border-radius: var(--r-ctl);
  font: 400 13.5px/1 var(--f-body);
  color: var(--a-ink);
  transition: border-color var(--t-ctl) var(--ease-brand),
              box-shadow var(--t-ctl) var(--ease-brand);
}
.inp input, .inp select {
  flex: 1;
  height: auto;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  color: inherit;
}
.inp.sm, input.sm { height: var(--h-ctl-sm); padding: 0 var(--sp-3); font-size: var(--fs-small); }
.inp:focus-within,
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(var(--rgb-focus-ring) / 0.18);
  outline: none;
}
/* The wrapper owns the focus ring. Without this the inner control paints a
   second one nested inside it — `.inp input` and `input:focus` are both
   (0,1,1), so the later focus rule wins on the child and the base reset's
   `box-shadow: none` never applies. Naming :focus here takes specificity to
   (0,2,1), which settles it. An unwrapped control still rings normally. */
.inp input:focus,
.inp select:focus,
.inp textarea:focus { box-shadow: none; }
.inp.err, input.err, select.err, textarea.err {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgb(var(--rgb-err) / 0.12);
}
.inp.dis, input:disabled, select:disabled, textarea:disabled {
  background: var(--app-surface-3);
  color: var(--a-muted);
  pointer-events: none;
}
textarea, .textarea {
  height: auto;
  min-height: 96px;
  align-items: flex-start;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-area);
  line-height: var(--lh-body);
  resize: vertical;
}
input[type="checkbox"], input[type="radio"] {
  width: auto;
  height: auto;
  accent-color: var(--accent);
}
input[type="file"] {
  height: auto;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-card-a);
  font-size: var(--fs-small);
}

/* ── A select wearing OUR chrome ───────────────────────────────────────────────
   `select, textarea` above already gives a <select> our box, our border and our
   radius. What it never did is take the browser's own arrow OUT of that box, so
   every select on the platform painted two chromes at once: our capsule with a
   UA triangle sitting inside it, at whatever size and colour that UA felt like.
   The owner walked the property editor on 2026-08-11 and called the fields
   awful; this is half of why.

   OPT-IN BY WRAPPER, and deliberately so. `appearance: none` on a bare `select`
   would strip the arrow from every select on every surface — Team's role
   picker, Site settings' language picker, the central console — and give back
   nothing, because a replaced element cannot carry a pseudo-element and has
   nowhere to hang a replacement. So the reset lives on `.sel-wrap > select` and
   the chevron on `.sel-wrap::after`: a control gains our arrow and loses the
   browser's in the same edit, and one can never happen without the other.

   THE CHEVRON IS TWO ROTATED BORDERS, NOT AN INLINE SVG. The obvious
   implementation is `background-image: url("data:image/svg+xml,…
   stroke='%23888780'…")`, and it slipped past every guard in this repo: hard
   rule 14 was enforced by a `#[0-9a-fA-F]{3,8}` scan, and a percent-encoded `#`
   is `%23`. That scan now reads `(?:#|%23)` and the data URI itself is banned
   in every stylesheet, both closed on 2026-08-11 — but the shape is worth
   knowing whatever the guard says. It would be the one colour on the page no
   theme could re-value: an agency's palette would move every border and leave
   the chevron grey. Two borders on a pseudo-element cost nothing and take a
   token, exactly as `.fsec-h::before` already draws the disclosure marker in
   admin.css. Pinned by tests/test_property_controls.py.

   The listbox rendered over this — because the OPEN list is drawn by the
   operating system and no stylesheet in any browser can reach it — attaches to
   `.sel-wrap` and owns these names, reserved here so nothing else can claim
   them: `.sel-trigger`, `.sel-list`, `.sel-opt`, and `.sel-wrap.open`. It
   SHIPPED, in static/js/property-select.js, and those four are styled in
   admin.css rather than here, because nothing renders them until that script
   runs and it runs only on the dashboard. Two more hooks belong to the same
   component and are equally not-to-be-reused: `data-sel` on the wrapper (the
   script's "I have taken this one" marker, and its idempotence guard) and
   `data-sel-filter` on the one input it may create.

   The native element stays in the DOM and keeps its `name`, so the form posts
   identically with JavaScript off. admin.css hides it with `opacity`, never
   `display: none` — an unrendered select cannot be focused, and Chrome then
   refuses to submit a form containing it with only a console line to show for
   it. The reasoning is written out in full beside that rule.
   ────────────────────────────────────────────────────────────────────────── */
.sel-wrap { position: relative; display: block; }
/* Two selectors, not a duplicate. `.inp.sm` above is (0,2,0) and writes the
   `padding` shorthand, so it beats a lone `.sel-wrap > select` (0,1,1) and
   slides a long option's text under the chevron on every `.inp sm` select —
   the whole of the property list's filter row. The `.inp` variant is (0,2,1)
   and settles it whatever the source order. */
.sel-wrap > select,
.sel-wrap > select.inp {
  appearance: none;
  -webkit-appearance: none;
  /* Clears the chevron: --sp-4 of inset, plus the glyph, plus a gap. A shorter
     value overlaps a long option's text instead of truncating it. */
  padding-right: var(--sp-8);
  cursor: pointer;
}
.sel-wrap::after {
  content: "";
  position: absolute;
  /* `right`, not `inset-inline-end`, deliberately — it has to pair with the
     `padding-right` above, and mixing a logical property with the physical
     `padding` shorthand `.inp.sm` writes puts the two in a cascade interaction
     nothing here needs. Every language this platform ships is LTR. */
  right: var(--sp-4);
  top: 50%;
  width: 6px;
  height: 6px;
  /* Half the rotated square's diagonal, so the V sits on the optical centre
     rather than hanging below it. */
  margin-top: -5px;
  border-right: 1.5px solid var(--a-muted);
  border-bottom: 1.5px solid var(--a-muted);
  transform: rotate(45deg);
  /* Without this the chevron swallows the click that should open the control —
     it sits directly over the select's right edge, which is exactly where
     people aim. */
  pointer-events: none;
  transition: border-color var(--t-ctl) var(--ease-brand);
}
.sel-wrap:hover::after { border-color: var(--a-ink); }

.hint { font-size: 12px; line-height: var(--lh-small); color: var(--a-muted); }
.hint.err { color: var(--err); }
.opt { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--a-body); }

/* Segmented control — deterministic 32px total, 3 + 26 + 3. */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--app-surface-3); border-radius: var(--r-ctl); }
.seg b {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-ctl);
  font-size: var(--fs-small);
  font-weight: 500;
  letter-spacing: var(--ls-ui);
  color: var(--a-muted);
  cursor: pointer;
}
.seg b.on { background: var(--app-surface); color: var(--a-ink); box-shadow: 0 1px 3px rgb(var(--rgb-ink) / 0.08); }

/* ── Cards ────────────────────────────────────────────────────────────────────
   Hairline, never shadow. Shadow is reserved for things that float.
   ────────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--app-surface);
  border: 1px solid var(--line-lt-1);
  border-radius: var(--r-card-a);
  padding: var(--sp-5);
}
.card.tight { padding: var(--sp-4); }
.card-title {
  font-size: var(--fs-card-title);
  color: var(--a-ink);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  margin-bottom: var(--sp-3);
}
.cardhead { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.cardhead .card-title { margin-bottom: 0; }
.cardhead .sp { margin-left: auto; }
.section-title {
  font-size: var(--fs-section);
  color: var(--a-ink);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
}

/* ── Chips and badges — a fixed 22px capsule ─────────────────────────────────
   Each chip prints its own label, so the hue only ever reinforces the text.
   Status is never conveyed by colour alone.
   ────────────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-ctl);
  font-family: var(--f-mono);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--app-surface-3);
  color: var(--a-body);
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip.c1 { background: var(--cat-1-tint); color: var(--cat-1); }
.chip.c2 { background: var(--cat-2-tint); color: var(--cat-2); }
.chip.c3 { background: var(--cat-3-tint); color: var(--cat-3); }
.chip.c4 { background: var(--cat-4-tint); color: var(--cat-4); }
.chip.c5 { background: var(--cat-5-tint); color: var(--cat-5); }
.chip.c6 { background: var(--cat-6-tint); color: var(--cat-6); }
.chip.c7 { background: var(--cat-7-tint); color: var(--cat-7); }
.chip.c8 { background: var(--cat-8-tint); color: var(--cat-8); }

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-ctl);
  font-size: var(--fs-tlabel);
  font-weight: 500;
  line-height: 1;
  background: var(--app-surface-3);
  color: var(--a-body);
}
.badge.ok { background: var(--ok-tint); color: var(--ok); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.err { background: var(--err-tint); color: var(--err); }
.badge.info { background: var(--info-tint); color: var(--info); }

/* The honesty line — names where a figure came from and when it was read. */
.source {
  font-family: var(--f-mono);
  font-size: 10.5px;
  letter-spacing: var(--ls-mono-2);
  line-height: 1.4;
  text-transform: uppercase;
  color: var(--a-muted);
  border-top: 1px solid var(--line-lt-1);
  padding-top: var(--sp-2);
  margin-top: var(--sp-4);
}

/* ── Banners — Django messages ────────────────────────────────────────────── */
.banners { list-style: none; padding: 0; margin: 0 0 var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.banner {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-card-a);
  font-size: 13px;
  line-height: var(--lh-body);
  background: var(--app-surface-3);
  color: var(--a-body);
}
.banner.ok { background: var(--ok-tint); color: var(--ok); }
.banner.warn { background: var(--warn-tint); color: var(--warn); }
.banner.err, .banner.error { background: var(--err-tint); color: var(--err); }
.banner.info { background: var(--info-tint); color: var(--info); }
.banner.success { background: var(--ok-tint); color: var(--ok); }
.banner p { margin: 0; }

/* ── Tables — 40px rows, 36px header ──────────────────────────────────────── */
.tblwrap { border: 1px solid var(--line-lt-1); border-radius: var(--r-card-a); overflow: hidden; background: var(--app-surface); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; background: var(--app-surface); }
.tbl th {
  background: var(--app-surface-2);
  color: var(--a-muted);
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: var(--fs-tlabel);
  line-height: 16px;
  letter-spacing: var(--ls-mono-1);
  text-transform: uppercase;
  text-align: left;
  padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line-lt-1);
  white-space: nowrap;
}
.tbl td {
  padding: 11px var(--sp-4);
  line-height: 18px;
  border-bottom: 1px solid var(--line-lt-1);
  color: var(--a-body);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--app-surface-2); }
.tbl tr.sel td { background: var(--accent-tint); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .name { color: var(--a-ink); font-weight: 500; }
.tbl.dense td { padding: 7px var(--sp-4); }
.tbl.dense th { padding: var(--sp-2) var(--sp-4); }
.tbl-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 10px var(--sp-4);
  background: var(--app-surface);
  border-top: 1px solid var(--line-lt-1);
  font-size: var(--fs-small);
  color: var(--a-muted);
}
.toolbar { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.toolbar .sp { flex: 1; }

/* ── Tabs, stepper, pagination ────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-lt-1); }
.tab {
  padding: 10px var(--sp-4);
  font-size: 13.5px;
  line-height: 20px;
  letter-spacing: var(--ls-ui);
  color: var(--a-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--a-body); text-decoration: none; }
.tab.on { color: var(--accent-ink); border-bottom-color: var(--accent-ink); font-weight: 500; }
.pgn { display: flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-small); color: var(--a-muted); }
.pgn a, .pgn b {
  min-width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-ctl);
  font-weight: 400;
  color: var(--a-body);
}
.pgn a:hover { background: var(--app-surface-2); text-decoration: none; }
.pgn b.on { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }

/* ── Overlays — the only place shadow is allowed ──────────────────────────── */
.menu {
  background: var(--app-surface);
  border: 1px solid var(--line-lt-1);
  border-radius: var(--r-menu);
  box-shadow: var(--shadow-menu);
  padding: 6px;
  min-width: 180px;
  z-index: var(--z-dropdown);
}
.mi { display: flex; align-items: center; gap: 10px; padding: var(--sp-2) 10px; border-radius: var(--sp-2); font-size: 13px; color: var(--a-body); }
.mi:hover { background: var(--app-surface-2); text-decoration: none; }
.mi.on { background: var(--accent-tint); color: var(--accent-ink); }
.mi.danger { color: var(--err); }
.msep { height: 1px; background: var(--line-lt-1); margin: 5px var(--sp-1); }
.sep { height: 1px; background: var(--line-lt-1); margin: var(--sp-1) 0; }

/* ── Empty and skeleton states ────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-9) var(--sp-6);
  gap: var(--sp-2);
}
.empty .art {
  width: 88px;
  height: 64px;
  border: 1.5px dashed var(--line-lt-3);
  border-radius: var(--sp-3);
  margin-bottom: var(--sp-2);
  position: relative;
}
.empty .art::after { content: ""; position: absolute; inset: 10px; border-radius: var(--sp-2); background: var(--app-surface-3); }
.empty h3 { font-size: var(--fs-card-title); }
.empty p { color: var(--a-muted); font-size: var(--fs-small); line-height: var(--lh-small); max-width: 360px; }
.skel {
  background: linear-gradient(90deg, var(--app-surface-3) 25%, var(--app-surface-2) 50%, var(--app-surface-3) 75%);
  background-size: 200% 100%;
  border-radius: var(--sp-2);
  animation: kit-shimmer 1.4s infinite;
}
@keyframes kit-shimmer { to { background-position: -200% 0; } }

/* ── Layout helpers ───────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--gutter); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack-form { max-width: 34rem; }

/* Spacing utilities. These exist so no template needs an inline style
   attribute — see the plan's Global Constraints. */
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-9 { margin-bottom: var(--sp-9); }
.inline-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
/* Wrapper so an inline control can carry a visually-hidden label without the
   label's absolute positioning collapsing the flex row. */
.field-inline { display: contents; }

/* A read-only field holding a link for the user to copy. */
.copyable {
  min-width: 18rem;
  font-family: var(--f-mono);
  font-size: 11.5px;
  background: var(--app-surface-2);
}

@media (max-width: 60rem) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-3, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 30rem) {
  .cols-4 { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
