body>header {
  padding-top: 0;
}

/* Top menu: inline on wide screens. On narrow screens, and on pages that
   take the whole window (an element with data-layout="full"), the links move
   into a side panel opened by any [data-nav-open] button (ui.js). */
.nav-links {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
}

.nav-links>ul:first-of-type {
  margin-left: 0;
}

.nav-toggle,
.nav-backdrop {
  display: none;
}

[data-nav-open] {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.45rem;
  line-height: 0;
  color: var(--app-text);
  background: none;
  border: none;
  box-shadow: none;
}

[data-nav-open]:hover {
  background: var(--app-subtle);
}

@media (max-width: 900px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
  }
}

body:has([data-layout="full"])>header {
  padding: 0;
}

body:has([data-layout="full"])>header>nav>:not(.nav-links),
body:has([data-layout="full"]) .nav-links,
body:has([data-layout="full"])>footer {
  display: none;
}

:root.nav-open .nav-links {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  width: min(18rem, 85vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  overflow-y: auto;
  background: var(--app-surface);
  border-right: 1px solid var(--app-border);
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.12);
}

:root.nav-open .nav-links ul {
  flex-direction: column;
  align-items: stretch;
  margin: 0;
}

:root.nav-open .nav-links ul+ul {
  border-top: 1px solid var(--app-border);
  padding-top: 0.5rem;
}

:root.nav-open .nav-links li {
  display: block;
  padding: 0;
}

:root.nav-open .nav-links li>a,
:root.nav-open .nav-links summary {
  display: block;
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-radius: var(--app-radius);
}

:root.nav-open .nav-links details.dropdown>summary {
  height: auto;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--app-accent-tone);
}

:root.nav-open .nav-links details.dropdown>ul {
  position: static;
  direction: ltr;
  min-width: 0;
  margin: 0 0 0 0.75rem;
  padding: 0;
  border: none;
  box-shadow: none;
  background: none;
}

:root.nav-open .nav-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(17, 24, 39, 0.25);
}

.shake {
  display: inline-block;
}

#dark-mode-icon {
  fill: currentColor;
}

.is-between,
.is-center,
.is-right,
.is-left {
  display: flex;
  align-items: center;
}

.is-between {
  justify-content: space-between;
}

.is-center {
  justify-content: center;
}

.is-right {
  justify-content: flex-end;
}

.is-left {
  justify-content: flex-start;
}

.nowrap {
  white-space: nowrap;
}

/* Filter form: search flexes, other fields size to content, never wraps until mobile */
.filter-form {
  display: flex;
  flex-wrap: nowrap;
  align-items: end;
  gap: var(--app-space);
  margin-bottom: 2rem;
}

.filter-form>label {
  flex: 0 0 auto;
}

.filter-form>label:first-child {
  flex: 1 1 auto;
  min-width: 8rem;
}

.filter-form>label,
.filter-form>button {
  margin-bottom: 0;
}

/* Filters (partials/filters.html): with them the form wraps, each control its own size. */
.filter-form:has(.filter-range, select, .saved-views) { flex-wrap: wrap; align-items: center; }
.filter-form > select, .filter-form > input:not([type="search"]) { width: auto; margin-bottom: 0; }
.filter-range { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; padding: 0; border: 0; }
.filter-range > span:first-child { color: var(--app-muted); font-size: 0.9rem; }
.filter-range input { width: auto; max-width: 10rem; margin-bottom: 0; }
.filter-check { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; white-space: nowrap; }
.filter-clear { font-size: 0.9rem; white-space: nowrap; }
.saved-views { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.saved-view { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.15rem 0.6rem; border: 1px solid var(--app-border);
  border-radius: 999px; font-size: 0.88rem; }
.saved-view a { text-decoration: none; }
.saved-view-x { all: unset; cursor: pointer; color: var(--app-muted); padding: 0 0.15rem; }
.save-view { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.88rem; }
.save-view[open] { flex-wrap: wrap; }
.save-view > summary { cursor: pointer; color: var(--app-accent-tone); list-style: none; }
.save-view input[type="text"] { width: 12rem; margin: 0; padding: 0.3rem 0.5rem; }

/* Acting on several rows: checkboxes named ids[] in a form, and its bar of
   actions, shown while some are ticked (docs: lists). */
.bulk-bar { display: none; align-items: center; gap: var(--app-space); padding: 0.5rem 0.75rem; margin-bottom: 0.75rem;
  border-radius: var(--app-radius); background: var(--app-subtle); }
form:has(input[name="ids[]"]:checked) .bulk-bar { display: flex; }
.bulk-bar button { margin: 0; }
td.pick, th.pick { width: 2rem; }

/* The label wrapper's own margin is already zeroed above, but the base also
   puts a margin-bottom on the input/select it wraps - without this the
   label's box is taller than the visible control, so the control itself
   sits above the button instead of sharing its bottom edge. */
.filter-form input,
.filter-form select {
  margin-bottom: 0;
}

.filter-form>button {
  flex: 0 0 auto;
  width: auto;
  /* Beside a field, the button is as tall as the field. */
  align-self: stretch;
}

@media (max-width: 768px) {
  .filter-form {
    flex-wrap: wrap;
  }

  .filter-form>label {
    flex: 1 1 100%;
  }
}

.mb2 {
  margin-bottom: 2rem;
}

.mt2 {
  margin-top: 2rem;
}

/* Ensure SVGs inside buttons don't block click events */
button svg,
a svg {
  pointer-events: none;
}

/* Tags - small status indicators */
.tag {
  /* Every tag is the same box (a border even when not drawn), its text in the middle,
     so tags of different kinds line up side by side. */
  display: inline-flex;
  align-items: center;
  padding: 0.5em;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  border-radius: var(--app-radius);
  white-space: nowrap;
  vertical-align: middle;
}

.tag-success {
  background-color: var(--color-success);
  color: #fff;
}

.tag-error {
  background-color: var(--color-error);
  color: #fff;
}

.tag-warning {
  background-color: var(--color-warning);
  color: #000;
}

.tag-info {
  background-color: var(--color-info);
  color: #fff;
}

.tag-primary {
  background-color: var(--app-accent-tone);
  color: var(--app-on-accent);
}

/* Outline variants */
.tag-outline {
  background-color: transparent;
  border: 1px solid currentColor;
}

.tag-outline.tag-success {
  color: var(--color-success);
}

.tag-outline.tag-error {
  color: var(--color-error);
}

.tag-outline.tag-warning {
  color: var(--color-warning);
}

.tag-outline.tag-info {
  color: var(--color-info);
}

.tag-outline.tag-primary {
  color: var(--color-primary);
}

/* Overdue date (past due, unpaid) — readable on light and dark themes */
.is-overdue {
  color: var(--color-error);
  font-weight: 600;
}

/* Generic actions column alignment for any table */
.table-actions th:last-child,
.table-actions td:last-child {
  text-align: right;
}

/* An empty list's one cell ("No results") stays centred. */
.table-actions td.text-center {
  text-align: center;
}

/* Vertically center all cells in table-actions rows */
.table-actions th,
.table-actions td {
  vertical-align: middle;
}

/* Space buttons/links without needing a flex wrapper */
.table-actions td:last-child .button+.button,
.table-actions td:last-child a.button+.button,
.table-actions td:last-child .button+a.button,
.table-actions td:last-child a.button+a.button {
  margin-left: 0.5rem;
}

.table-actions td:last-child {
  white-space: nowrap;
}

footer {
  border-top: 1px solid var(--app-border);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  [data-slot] {
    transition: none !important;
  }
}

:where(a:not([role=button])):is([aria-current]:not([aria-current=false]), :hover, :active, :focus),
[role=link]:is([aria-current]:not([aria-current=false]), :hover, :active, :focus) {
  text-decoration: underline;
}

.small {
  padding: 0.25rem 0.45rem;
}

.capitalize {
  text-transform: capitalize;
}

.row {
  display: flex;
  flex-flow: row wrap;
  justify-content: flex-start;
  align-items: baseline;
  margin-left: calc(var(--grid-gutter)/-2);
  margin-right: calc(var(--grid-gutter)/-2)
}

.row.reverse {
  flex-direction: row-reverse
}

.col {
  flex: 1
}

.col,
[class*=" col-"],
[class^=col-] {
  margin: 0 calc(var(--grid-gutter)/2) calc(var(--grid-gutter)/2)
}

.col-1 {
  flex: 0 0 calc(8.33333% - var(--grid-gutter));
  max-width: calc(8.33333% - var(--grid-gutter))
}

.col-2 {
  flex: 0 0 calc(16.66667% - var(--grid-gutter));
  max-width: calc(16.66667% - var(--grid-gutter))
}

.col-3 {
  flex: 0 0 calc(25% - var(--grid-gutter));
  max-width: calc(25% - var(--grid-gutter))
}

.col-4 {
  flex: 0 0 calc(33.33333% - var(--grid-gutter));
  max-width: calc(33.33333% - var(--grid-gutter))
}

.col-5 {
  flex: 0 0 calc(41.66667% - var(--grid-gutter));
  max-width: calc(41.66667% - var(--grid-gutter))
}

.col-6 {
  flex: 0 0 calc(50% - var(--grid-gutter));
  max-width: calc(50% - var(--grid-gutter))
}

.col-7 {
  flex: 0 0 calc(58.33333% - var(--grid-gutter));
  max-width: calc(58.33333% - var(--grid-gutter))
}

.col-8 {
  flex: 0 0 calc(66.66667% - var(--grid-gutter));
  max-width: calc(66.66667% - var(--grid-gutter))
}

.col-9 {
  flex: 0 0 calc(75% - var(--grid-gutter));
  max-width: calc(75% - var(--grid-gutter))
}

.col-10 {
  flex: 0 0 calc(83.33333% - var(--grid-gutter));
  max-width: calc(83.33333% - var(--grid-gutter))
}

.col-11 {
  flex: 0 0 calc(91.66667% - var(--grid-gutter));
  max-width: calc(91.66667% - var(--grid-gutter))
}

.col-12 {
  flex: 0 0 calc(100% - var(--grid-gutter));
  max-width: calc(100% - var(--grid-gutter))
}

@media screen and (max-width:599px) {
  .container {
    width: 100%
  }

  .col,
  [class*=col-],
  [class^=col-] {
    flex: 0 1 100%;
    max-width: 100%
  }
}

@media screen and (min-width:900px) {
  .col-1-md {
    flex: 0 0 calc(8.33333% - var(--grid-gutter));
    max-width: calc(8.33333% - var(--grid-gutter))
  }

  .col-2-md {
    flex: 0 0 calc(16.66667% - var(--grid-gutter));
    max-width: calc(16.66667% - var(--grid-gutter))
  }

  .col-3-md {
    flex: 0 0 calc(25% - var(--grid-gutter));
    max-width: calc(25% - var(--grid-gutter))
  }

  .col-4-md {
    flex: 0 0 calc(33.33333% - var(--grid-gutter));
    max-width: calc(33.33333% - var(--grid-gutter))
  }

  .col-5-md {
    flex: 0 0 calc(41.66667% - var(--grid-gutter));
    max-width: calc(41.66667% - var(--grid-gutter))
  }

  .col-6-md {
    flex: 0 0 calc(50% - var(--grid-gutter));
    max-width: calc(50% - var(--grid-gutter))
  }

  .col-7-md {
    flex: 0 0 calc(58.33333% - var(--grid-gutter));
    max-width: calc(58.33333% - var(--grid-gutter))
  }

  .col-8-md {
    flex: 0 0 calc(66.66667% - var(--grid-gutter));
    max-width: calc(66.66667% - var(--grid-gutter))
  }

  .col-9-md {
    flex: 0 0 calc(75% - var(--grid-gutter));
    max-width: calc(75% - var(--grid-gutter))
  }

  .col-10-md {
    flex: 0 0 calc(83.33333% - var(--grid-gutter));
    max-width: calc(83.33333% - var(--grid-gutter))
  }

  .col-11-md {
    flex: 0 0 calc(91.66667% - var(--grid-gutter));
    max-width: calc(91.66667% - var(--grid-gutter))
  }

  .col-12-md {
    flex: 0 0 calc(100% - var(--grid-gutter));
    max-width: calc(100% - var(--grid-gutter))
  }
}

@media screen and (min-width:1200px) {
  .col-1-lg {
    flex: 0 0 calc(8.33333% - var(--grid-gutter));
    max-width: calc(8.33333% - var(--grid-gutter))
  }

  .col-2-lg {
    flex: 0 0 calc(16.66667% - var(--grid-gutter));
    max-width: calc(16.66667% - var(--grid-gutter))
  }

  .col-3-lg {
    flex: 0 0 calc(25% - var(--grid-gutter));
    max-width: calc(25% - var(--grid-gutter))
  }

  .col-4-lg {
    flex: 0 0 calc(33.33333% - var(--grid-gutter));
    max-width: calc(33.33333% - var(--grid-gutter))
  }

  .col-5-lg {
    flex: 0 0 calc(41.66667% - var(--grid-gutter));
    max-width: calc(41.66667% - var(--grid-gutter))
  }

  .col-6-lg {
    flex: 0 0 calc(50% - var(--grid-gutter));
    max-width: calc(50% - var(--grid-gutter))
  }

  .col-7-lg {
    flex: 0 0 calc(58.33333% - var(--grid-gutter));
    max-width: calc(58.33333% - var(--grid-gutter))
  }

  .col-8-lg {
    flex: 0 0 calc(66.66667% - var(--grid-gutter));
    max-width: calc(66.66667% - var(--grid-gutter))
  }

  .col-9-lg {
    flex: 0 0 calc(75% - var(--grid-gutter));
    max-width: calc(75% - var(--grid-gutter))
  }

  .col-10-lg {
    flex: 0 0 calc(83.33333% - var(--grid-gutter));
    max-width: calc(83.33333% - var(--grid-gutter))
  }

  .col-11-lg {
    flex: 0 0 calc(91.66667% - var(--grid-gutter));
    max-width: calc(91.66667% - var(--grid-gutter))
  }

  .col-12-lg {
    flex: 0 0 calc(100% - var(--grid-gutter));
    max-width: calc(100% - var(--grid-gutter))
  }
}

/* Fullscreen dialog modifier */
dialog.fullscreen,
dialog.fullscreen > article {
  width: 100%;
  max-width: 98%;
  height: auto;
  max-height: 95%;
  border-radius: var(--app-radius);
}

/* Large dialog - useful for complex forms */
dialog.large > article {
  max-width: 900px;
}

dialog.xlarge > article {
  max-width: 1200px;
}

dialog footer {
  padding-top: 1rem;
}

dialog button[type=submit] {
  width: auto;
}

/* Toast notifications */
#toast-root {
  position: fixed;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  pointer-events: none;
}

#toast-root.bottom-right {
  bottom: 0;
  right: 0;
  align-items: flex-end;
}

#toast-root.bottom-left {
  bottom: 0;
  left: 0;
  align-items: flex-start;
}

#toast-root.top-right {
  top: 0;
  right: 0;
  align-items: flex-end;
}

#toast-root.top-left {
  top: 0;
  left: 0;
  align-items: flex-start;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--app-radius);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 400px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-msg {
  flex: 1;
  font-size: 0.9rem;
}

.toast button {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: auto;
  line-height: 1;
  opacity: 0.8;
}

.toast button:hover {
  opacity: 1;
}

.toast.success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.toast.success button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.success button:hover {
  color: #fff;
}

.toast.error {
  background: var(--color-error);
  border-color: var(--color-error);
  color: #fff;
}

.toast.error button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.error button:hover {
  color: #fff;
}

.toast.warning {
  background: var(--color-warning);
  border-color: var(--color-warning);
  color: #000;
}

.toast.warning button {
  color: rgba(0, 0, 0, 0.6);
}

.toast.warning button:hover {
  color: #000;
}

.toast.info {
  background: var(--color-info);
  border-color: var(--color-info);
  color: #fff;
}

.toast.info button {
  color: rgba(255, 255, 255, 0.7);
}

.toast.info button:hover {
  color: #fff;
}

/* Calendar (partials/calendar.html) */
.calendar {
  --cal-line: var(--app-border);
  --cal-hour: 3rem;
  margin-bottom: 1rem;
}

.cal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.cal-nav,
.cal-views {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cal-title {
  margin: 0 0 0 0.5rem;
  font-size: 1.15rem;
  white-space: nowrap;
}

.cal-btn {
  width: auto;
  margin: 0;
  padding: 0.3rem 0.7rem;
  font-size: 0.9rem;
  color: var(--app-text);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  box-shadow: none;
}

.cal-btn:hover {
  background: var(--app-subtle);
}

.cal-btn[aria-pressed="true"] {
  background: var(--app-accent-soft);
  border-color: transparent;
  color: var(--app-accent-tone);
  font-weight: 600;
}

.cal-month {
  border: 1px solid var(--cal-line);
  border-radius: var(--app-radius);
  overflow: hidden;
  background: var(--app-surface);
}

.cal-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-row+.cal-row {
  border-top: 1px solid var(--cal-line);
}

.cal-head div {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: var(--app-muted);
}

.cal-cell {
  min-height: 6.5rem;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cal-cell+.cal-cell {
  border-left: 1px solid var(--cal-line);
}

.cal-cell.is-out {
  background: var(--app-subtle);
}

.cal-cell.is-out .cal-daynum {
  color: var(--app-muted);
}

.calendar button.cal-daynum,
.calendar button.cal-more,
.cal-colhead button {
  width: auto;
  margin: 0;
  padding: 0.05rem 0.4rem;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--app-text);
  font-size: 0.85rem;
  border-radius: 999px;
  align-self: flex-start;
}

.cal-cell.is-today .cal-daynum {
  background: var(--app-accent-tone);
  color: var(--app-on-accent);
  font-weight: 600;
}

.calendar button.cal-more {
  color: var(--app-muted);
  font-size: 0.78rem;
}

.cal-ev {
  --ev: var(--app-accent-tone);
  display: block;
  min-width: 0;
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  border-left: 3px solid var(--ev);
  background: color-mix(in srgb, var(--ev) 14%, var(--app-surface));
  color: var(--app-text);
  font-size: 0.8rem;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-ev:hover {
  background: color-mix(in srgb, var(--ev) 24%, var(--app-surface));
  color: var(--app-text);
}

.cal-ev[draggable="true"] {
  cursor: grab;
}

.cal-ev.is-dragging {
  opacity: 0.45;
}

.cal-ev.is-cont {
  border-left-style: dashed;
}

.cal-time {
  color: var(--app-muted);
  font-variant-numeric: tabular-nums;
}

.cal-c-blue { --ev: #3b82f6; }
.cal-c-green { --ev: #2f9e75; }
.cal-c-amber { --ev: #d99a1e; }
.cal-c-red { --ev: #d14b4b; }
.cal-c-violet { --ev: #8b5cf6; }
.cal-c-teal { --ev: #0d9488; }
.cal-c-gray { --ev: #8a919c; }

.is-drop {
  background: var(--app-accent-soft) !important;
}

.cal-scroll {
  overflow-x: auto;
  border: 1px solid var(--cal-line);
  border-radius: var(--app-radius);
  background: var(--app-surface);
}

.cal-grid {
  display: grid;
  grid-template-columns: 3.5rem repeat(var(--cal-cols), minmax(7rem, 1fr));
  grid-template-rows: auto auto calc(var(--cal-hours) * var(--cal-hour));
}

.cal-day .cal-grid {
  grid-template-columns: 3.5rem repeat(var(--cal-cols), minmax(10rem, 1fr));
}

.cal-colhead {
  padding: 0.4rem;
  text-align: center;
  font-size: 0.85rem;
  border-left: 1px solid var(--cal-line);
  border-bottom: 1px solid var(--cal-line);
}

.cal-colhead.is-today strong {
  color: var(--app-accent-tone);
}

.cal-corner,
.cal-allday-label {
  border-bottom: 1px solid var(--cal-line);
}

.cal-allday-label {
  font-size: 0.7rem;
  color: var(--app-muted);
  padding: 0.3rem 0.25rem;
  text-align: right;
}

.cal-allday {
  min-height: 1.8rem;
  padding: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 1px solid var(--cal-line);
  border-bottom: 1px solid var(--cal-line);
}

.cal-hours div {
  height: var(--cal-hour);
  padding: 0.15rem 0.35rem 0;
  font-size: 0.72rem;
  color: var(--app-muted);
  text-align: right;
}

.cal-col {
  position: relative;
  border-left: 1px solid var(--cal-line);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--cal-hour) - 1px), var(--cal-line) calc(var(--cal-hour) - 1px), var(--cal-line) var(--cal-hour));
}

.cal-col.is-today {
  background-color: color-mix(in srgb, var(--app-accent-tone) 4%, transparent);
}

.cal-ev.is-timed {
  position: absolute;
  margin: 0 2px;
  box-sizing: border-box;
  max-width: calc(100% - 4px);
  white-space: normal;
}

[data-create] .cal-cell,
[data-create] .cal-col,
[data-create] .cal-allday {
  cursor: cell;
}

/* Board (partials/board.html) */
.board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(15rem, 1fr);
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  align-items: start;
}

.board-col {
  background: var(--app-subtle);
  border-radius: var(--app-radius);
  padding: 0.5rem;
  min-width: 0;
  border-top: 3px solid var(--app-border);
}

.board-col[class*="cal-c-"] {
  border-top-color: var(--ev);
}

.board-col.is-drop {
  background: var(--app-accent-soft);
}

.board-col-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0.25rem 0.5rem;
  font-size: 0.9rem;
}

.board-count {
  color: var(--app-muted);
  font-size: 0.8rem;
}

.board .board-add {
  width: auto;
  margin: 0 0 0 auto;
  padding: 0 0.5rem;
  line-height: 1.6;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--app-muted);
  font-size: 1.1rem;
  border-radius: 999px;
}

.board .board-add:hover {
  background: var(--app-surface);
  color: var(--app-text);
}

.board-cards {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 3rem;
}

.board-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.65rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-left: 3px solid var(--app-border);
  border-radius: 0.5rem;
  color: var(--app-text);
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: var(--app-shadow);
}

.board-card.has-edge {
  border-left-color: var(--ev);
}

.board-card:hover {
  color: var(--app-text);
  border-color: color-mix(in srgb, var(--app-accent-tone) 40%, var(--app-border));
}

.board-card.has-edge:hover {
  border-left-color: var(--ev);
}

.board-card[draggable="true"] {
  cursor: grab;
}

.board-card.is-dragging {
  opacity: 0.4;
}

.board-card.is-disabled {
  opacity: 0.6;
}

.board-meta {
  color: var(--app-muted);
  font-size: 0.8rem;
}

.board-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.board-tags span {
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--app-subtle);
  color: var(--app-muted);
  font-size: 0.72rem;
}

.board-empty {
  margin: 0;
  padding: 0.75rem 0.25rem;
  color: var(--app-muted);
  font-size: 0.85rem;
  text-align: center;
}

.board-cards:has(.board-card) .board-empty {
  display: none;
}

/* Activity (partials/activity.html) */
.activity-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.activity-form textarea {
  margin: 0;
  min-height: 2.6rem;
  resize: vertical;
}

.activity-form button {
  width: auto;
  margin: 0;
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-item {
  list-style: none;
  position: relative;
  margin: 0;
  padding: 0 0 0.9rem 1.1rem;
  border-left: 2px solid var(--app-border);
}

.activity-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.45rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--app-border);
}

.activity-item.is-comment::before {
  background: var(--app-accent-tone);
}

.activity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.88rem;
}

.activity-head span,
.activity-head time {
  color: var(--app-muted);
}

.activity-head time {
  font-size: 0.8rem;
}

/* The channel beside the event: "via Claude", "automatically" */
.activity-via,
.audit-via {
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--app-info-soft);
  color: var(--app-info);
  font-size: 0.75rem;
  white-space: nowrap;
}

.activity .activity-delete {
  width: auto;
  margin: 0 0 0 auto;
  padding: 0 0.4rem;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--app-muted);
}

.activity-body {
  margin-top: 0.3rem;
  padding: 0.5rem 0.7rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.activity-changes {
  margin: 0.25rem 0 0;
  padding: 0;
  font-size: 0.85rem;
}

.activity-changes li {
  list-style: none;
  margin: 0;
}

.activity-changes span {
  color: var(--app-muted);
}

.activity-changes del {
  color: var(--app-muted);
}

.activity-changes ins {
  text-decoration: none;
  font-weight: 500;
}

.activity-empty {
  list-style: none;
  color: var(--app-muted);
  font-size: 0.88rem;
}

/* Attachments (partials/attachments.html) */
.attachment-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
}

.attachment-list li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--app-border);
}

.attachment-file {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  text-decoration: none;
}

.attachment-file img,
.attachment-icon {
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
  object-fit: cover;
  border-radius: 0.4rem;
  background: var(--app-subtle);
  display: grid;
  place-items: center;
  color: var(--app-muted);
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-meta {
  margin-left: auto;
  flex: none;
  color: var(--app-muted);
  font-size: 0.8rem;
}

.attachments .attachment-delete {
  width: auto;
  margin: 0;
  padding: 0 0.4rem;
  border: none;
  background: none;
  box-shadow: none;
  color: var(--app-muted);
}

.attachment-empty {
  color: var(--app-muted);
  font-size: 0.88rem;
}

.attachment-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.attachment-form input[type="file"] {
  flex: 1;
  margin: 0;
}

.attachment-form button {
  width: auto;
  margin: 0;
}

.attachment-form small {
  width: 100%;
  color: var(--app-muted);
}

@media (max-width: 600px) {
  .attachment-meta {
    display: none;
  }
}

/* CSV import (partials/import.html) */
.import .import-map {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0 1rem;
}

.import-preview-title {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--app-muted);
}

.import-preview table {
  font-size: 0.8rem;
  margin: 0;
}

.import-preview th,
.import-preview td {
  white-space: nowrap;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-errors {
  max-height: 16rem;
  overflow-y: auto;
  font-size: 0.88rem;
  color: var(--app-danger);
}

/* Notifications (bell in nav.html, /notifications) */
.notify-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.notify-bell .notify-label {
  display: none;
}

:root.nav-open .notify-bell .notify-label {
  display: inline;
}

.notify-count {
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--app-danger);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

.notify-bell .notify-count {
  position: absolute;
  top: -0.45rem;
  right: -0.6rem;
}

:root.nav-open .notify-bell .notify-count {
  position: static;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  overflow: hidden;
}

.notification-list li {
  display: flex;
  align-items: stretch;
  list-style: none;
  margin: 0;
}

.notification-list li+li {
  border-top: 1px solid var(--app-border);
}

.notification-list button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--app-text);
  text-align: left;
}

.notification-list button:hover {
  background: var(--app-subtle);
}

.notification-list .is-unread button {
  background: var(--app-accent-soft);
  font-weight: 500;
}

/* × beside each notification: removes it. */
.notification-list button.notification-remove {
  flex: none;
  width: auto;
  align-items: center;
  justify-content: center;
  padding: 0 0.85rem;
  color: var(--app-muted);
}

.notification-list button.notification-remove:hover {
  color: var(--app-danger);
}

.notification-remove svg {
  width: 1rem;
  height: 1rem;
}

.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.notification-actions button {
  margin: 0;
}

/* On a phone the actions get their own row under the title, side by side. */
@media (max-width: 600px) {
  .notification-head {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .notification-head h1 {
    margin: 0;
  }

  .notification-actions {
    flex-wrap: nowrap;
    width: 100%;
  }

  .notification-actions button {
    flex: 1;
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
  }
}

.notification-meta {
  color: var(--app-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.notification-empty {
  padding: 1rem;
  color: var(--app-muted);
}

/* Unread notifications while the menu is folded into ☰: a dot on the button. */
body:has(.notify-count) [data-nav-open] {
  position: relative;
}

body:has(.notify-count) [data-nav-open]::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  right: 0.2rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--app-danger);
}

/* Invites */
form:has([name="invite"]:checked) .password-field {
  display: none;
}

.badge-invited {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--app-warning-soft);
  color: var(--app-warning);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Charts (partials/chart.html): SVG drawn by the server. A colour class
   (cal-c-*) sets --ev; without one it is the app's accent. */
.chart {
  --ev: var(--app-accent-tone);
  margin: 0 0 1rem;
}

.chart figcaption {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid {
  stroke: var(--app-border);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart-grid.is-zero {
  stroke: var(--app-border-strong);
}

.chart-tick {
  fill: var(--app-muted);
  font-size: 11px;
  font-family: inherit;
}

.chart-bar,
.chart-slice,
.chart-dot {
  fill: var(--ev);
}

.chart-slice {
  stroke: var(--app-surface);
  stroke-width: 1.5;
}

.chart-bar:hover,
.chart-slice:hover {
  opacity: 0.8;
}

.chart-line {
  fill: none;
  stroke: var(--ev);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-fill {
  fill: var(--ev);
  opacity: 0.15;
}

.chart-dot {
  stroke: var(--app-surface);
  stroke-width: 1.5;
}

.chart-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.85rem;
}

.chart-legend li {
  margin: 0;
  list-style: none;
}

.chart-key {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-right: 0.4rem;
  border-radius: 2px;
  background: var(--ev);
}

.chart.is-pie .chart-body,
.chart.is-donut .chart-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}

.chart.is-pie svg,
.chart.is-donut svg {
  width: min(12rem, 100%);
  flex: none;
}

.chart.is-pie .chart-legend,
.chart.is-donut .chart-legend {
  flex-direction: column;
  margin: 0;
}

/* A sparkline sits in a line of text or a table cell. */
.chart-spark {
  --ev: var(--app-accent-tone);
  display: inline-block;
  width: 6rem;
  height: 1.5rem;
  vertical-align: middle;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Map (partials/map.html, static/js/map.js; Leaflet draws into .map-canvas) */
.map {
  margin-bottom: 1rem;
}

.map-canvas {
  width: 100%;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-subtle);
  z-index: 0; /* Leaflet's layers stay under menus and dialogs */
  font: inherit;
}

.map-canvas.is-picking {
  cursor: crosshair;
}

/* Leaflet gives its controls and markers role=button: keep the app's button
   look off them. */
.map-canvas .leaflet-bar a,
.map-canvas a.leaflet-popup-close-button,
.map-canvas .map-pin {
  padding: 0;
  border: 0;
  border-radius: 0;
  transition: none;
}

.map-canvas .map-pin {
  background: none;
}

.map-canvas .leaflet-bar a {
  border-bottom: 1px solid #ccc;
}

/* A pin in the marker's colour (cal-c-*; none = the app's accent). */
.map-pin svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.45));
}

.map-pin path {
  fill: var(--ev, var(--app-accent-tone));
  stroke: #fff;
  stroke-width: 1.5;
}

.map-pin circle {
  fill: #fff;
}

.map-popup p {
  margin: 0.25rem 0;
  white-space: pre-line;
}

.map-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

.map-hint button {
  width: auto;
  margin: 0;
  flex: none;
}

/* --- The standard menu's groups (partials/nav.html) -------------------------
   Admin: a quiet dropdown with a gear; hidden while it holds no entry. The
   user's menu: their name, then profile, language and log out. */
nav .nav-admin:not(:has(ul li)) {
  display: none;
}

nav :is(.nav-admin, .nav-user) > details.dropdown > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-color: transparent;
  background: none;
  color: var(--app-accent-tone);
}

nav :is(.nav-admin, .nav-user) > details.dropdown > summary:hover,
nav :is(.nav-admin, .nav-user) > details.dropdown[open] > summary {
  background: var(--app-subtle);
}

/* The group that holds the open page is marked like a current link. */
nav :is(.nav-admin, .nav-user) > details.dropdown:has([aria-current="page"]) > summary > span {
  text-decoration: underline;
}

nav .nav-user summary > span {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

nav details.dropdown > ul li a[aria-current="page"] {
  color: var(--app-accent-tone);
  font-weight: 600;
}

/* Languages: a row of choices inside the user's menu. */
nav details.dropdown > ul li.nav-langs {
  display: flex;
  direction: ltr;
  gap: 0.25rem;
  padding: 0.35rem 0.75rem;
  border-block: 1px solid var(--app-border);
}

nav details.dropdown > ul li.nav-langs a {
  width: auto;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

/* The language in use is the filled one. */
nav details.dropdown > ul li.nav-langs a[aria-current="true"],
nav details.dropdown > ul li.nav-langs a[aria-current="true"]:is(:hover, :focus-visible) {
  background: var(--app-accent-tone);
  color: var(--app-on-accent);
  font-weight: 600;
  text-decoration: none;
  cursor: default;
}

:root.nav-open .nav-links :is(.nav-admin, .nav-user) > details.dropdown > summary {
  display: flex;
}

/* --- Pages: head, back link, tables as cards, row actions, facts -------------
   A page starts with an optional back link, then its head (.is-between: an
   hgroup with the title and one line of explanation, actions on the right).
   Lists are tables in a card; a record's fields are a dl.facts grid. */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.75rem -0.4rem;
  padding: 0.2rem 0.6rem 0.2rem 0.4rem;
  border-radius: 0.4rem;
  color: var(--app-muted);
  text-decoration: none;
}

.back-link::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.25rem;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.back-link:hover {
  background: var(--app-subtle);
  color: var(--app-text);
  text-decoration: none;
}

hgroup > p {
  color: var(--app-muted);
}

/* A table on its own is a card; inside a card it runs edge to edge. */
.overflow-auto:has(> table) {
  margin-bottom: var(--app-space);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: var(--app-surface);
}

.overflow-auto:has(> table) > table {
  margin: 0;
}

article > .overflow-auto:has(> table) {
  margin-inline: calc(var(--app-space) * -1);
  border: 0;
  border-radius: 0;
  background: none;
}

article > .overflow-auto:has(> table):last-child {
  margin-bottom: calc(var(--app-space) * -1);
}

article > header + .overflow-auto:has(> table) {
  margin-top: calc(var(--app-space) * -1);
}

.overflow-auto:has(> table) thead th {
  padding-block: 0.6rem;
  border-bottom-width: 1px;
  background: var(--app-subtle);
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.overflow-auto:has(> table) tbody tr:last-child > * {
  border-bottom: 0;
}

.overflow-auto:has(> table) tbody tr:hover > * {
  background: color-mix(in srgb, var(--app-subtle) 55%, transparent);
}

/* Row actions: quiet icon buttons at the right edge (a tooltip names each). */
td.actions,
th.actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

td.actions :is(button, [role="button"]) {
  --btn-now: transparent;
  --btn-color: var(--app-muted);
  display: inline-grid;
  place-items: center;
  width: auto;
  min-width: 1.9rem;
  min-height: 1.9rem;
  padding: 0.35rem;
  border-color: transparent;
  background: var(--btn-now);
  color: var(--btn-color);
  box-shadow: none;
  line-height: 0;
  vertical-align: middle;
}

td.actions :is(button, [role="button"]):hover {
  --btn-now: var(--app-subtle);
  --btn-color: var(--app-text);
}

td.actions :is(button, [role="button"])[data-action^="delete"]:hover {
  --btn-color: var(--app-danger);
}

td.actions svg {
  width: 1.1rem;
  height: 1.1rem;
  display: block;
}

/* Row actions as a "⋯" menu on narrow screens (partials/row_menu.html); on
   wide ones the toggle is hidden and the buttons sit in the cell as before. */
td.actions .row-menu-toggle {
  display: none;
}

.row-menu {
  display: contents;
}

@media (max-width: 768px) {
  td.actions .row-menu-toggle {
    display: inline-grid;
  }

  td.actions .row-menu-toggle[aria-expanded="true"] {
    --btn-now: var(--app-subtle);
    --btn-color: var(--app-text);
  }

  td.actions .row-menu {
    display: none;
  }

  /* Open: a box beside the toggle, fixed to the window (ys.js places it), so
     the table's scrolling does not cut it off. */
  td.actions .row-menu-toggle[aria-expanded="true"] + .row-menu {
    position: fixed;
    z-index: 99;
    display: flex;
    flex-direction: column;
    min-width: 10rem;
    padding: 0.25rem;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: var(--app-surface);
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
    text-align: left;
  }

  td.actions .row-menu :is(button, [role="button"]) {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    line-height: 1.3;
  }

  /* The tooltip becomes the label. */
  td.actions .row-menu [data-tooltip]::before {
    display: none;
  }

  td.actions .row-menu [data-tooltip]::after {
    content: attr(data-tooltip);
  }
}

/* Sortable column headers (partials/sort_th.html). */
th > .sort-link {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

th > .sort-link:hover,
th > .sort-link:focus-visible {
  text-decoration: underline;
}

.sort-arrow {
  display: inline-flex;
  flex-direction: column;
  font-size: 0.65em;
  line-height: 0.75;
  opacity: 0.35;
}

.sort-arrow.is-on {
  font-size: 0.75em;
  opacity: 1;
}

/* A record's fields: label over value, in as many columns as fit. */
dl.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.9rem 1.5rem;
  margin: 0;
}

dl.facts dt {
  color: var(--app-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

dl.facts dd {
  margin: 0.1rem 0 0;
  overflow-wrap: anywhere;
}

/* People or things in a card: one per row, details muted, state at the end. */
ul.rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

ul.rows > li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  margin: 0;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--app-border);
  list-style: none;
}

ul.rows > li:first-child {
  padding-top: 0;
}

ul.rows > li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

ul.rows > li > :last-child:not(:first-child) {
  margin-left: auto;
}

/* The count beside a card's title. */
.count {
  margin-left: 0.4rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--app-text) 10%, transparent);
  color: var(--app-text);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Buttons side by side (a card's head, a page's head). */
:not(td, th).actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

:not(td, th).actions > * {
  width: auto;
  margin: 0;
}

article > header :is(h1, h2, h3) {
  margin: 0;
  font-size: 1.25rem;
}

/* The menus hang from the right edge (dir="rtl"); their entries still read left to right. */
nav :is(.nav-admin, .nav-user) > details.dropdown > ul > li {
  direction: ltr;
}

nav :is(.nav-admin, .nav-user) > details.dropdown > ul {
  min-width: 11rem;
}

/* Row actions sit at the table's right edge: their tooltips open to the left,
   inside the card (above or centred they would be cut off, or make it scroll). */
td.actions [data-tooltip]::before {
  top: 50%;
  right: calc(100% + 0.4rem);
  bottom: auto;
  left: auto;
  transform: translate(0.25rem, -50%);
}

td.actions [data-tooltip]:is(:hover, :focus-visible)::before {
  transform: translate(0, -50%);
}

/* The menu's icons (bell, theme) are centred on the line of the links. */
nav li:has(> .notify-bell),
nav li:has(> #dark-mode) {
  display: flex;
  align-items: center;
}

nav li > :is(.notify-bell, #dark-mode) {
  display: inline-flex;
  align-items: center;
}

nav li > :is(.notify-bell, #dark-mode) svg {
  display: block;
}

/* A plain tag (no colour variant) is a quiet grey label. */
:where(.tag) {
  background: color-mix(in srgb, var(--app-text) 10%, transparent);
  color: var(--app-text);
}

/* --- Phones ---------------------------------------------------------------- */
/* A label only the menu panel shows (beside an icon that stands alone in the top menu). */
.nav-label {
  display: none;
}

:root.nav-open .nav-links .nav-label {
  display: inline;
  margin-left: 0.4rem;
}

:root.nav-open .nav-links #dark-mode {
  display: flex;
  align-items: center;
}

/* In the panel the languages stay a row of choices. */
:root.nav-open .nav-links details.dropdown > ul li.nav-langs {
  display: flex;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem;
  border: 0;
}

:root.nav-open .nav-links details.dropdown > ul li.nav-langs a {
  display: inline-block;
  width: auto;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}

/* A page's head: the button keeps its words on one line and drops under the
   title when there is no room beside it. */
.is-between {
  gap: 0.75rem;
}

.is-between > :is(button, [role="button"]),
.is-between > .actions {
  flex: none;
  white-space: nowrap;
}

@media (max-width: 576px) {
  .is-between:has(> hgroup) {
    flex-wrap: wrap;
  }

  /* Tables: tighter cells, and the row's actions stay in view while the rest scrolls. */
  th,
  td {
    padding-inline: 0.6rem;
  }

  td.actions,
  th.actions,
  .table-actions :is(th, td):last-child {
    position: sticky;
    right: 0;
    background: var(--app-surface);
    box-shadow: -1px 0 0 var(--app-border);
  }

  .overflow-auto:has(> table) thead th.actions,
  .overflow-auto:has(> table) .table-actions thead th:last-child {
    background: var(--app-subtle);
  }
}

/* The menu as a panel: a cross to close it, and no tooltips (its entries have labels). */
.nav-close {
  display: none;
}

:root.nav-open .nav-links .nav-close {
  display: block;
  align-self: flex-end;
  flex: none;
  width: 2rem;
  height: 2rem;
  margin: -0.4rem -0.2rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 0.4rem;
  background: var(--app-icon-close) no-repeat center / 1.15rem auto;
  box-shadow: none;
}

:root.nav-open .nav-links .nav-close:is(:hover, :focus-visible) {
  background-color: var(--app-subtle);
}

:root.nav-open .nav-links [data-tooltip]::before {
  display: none;
}

/* --- Dragging (static/js/drag.js: board cards, calendar entries) ------------
   What can be dragged shows it; a finger resting on it must not select text
   or open the link's menu. While dragging, a copy follows the pointer. */
.board-card[draggable="true"],
.cal-ev[draggable="true"] {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.drag-ghost {
  opacity: 0.92;
  box-shadow: 0 10px 28px rgb(0 0 0 / 0.28);
  rotate: 1.5deg;
  cursor: grabbing;
}

:root.is-dragging-something,
:root.is-dragging-something * {
  cursor: grabbing !important;
  user-select: none;
  -webkit-user-select: none;
}

/* The focused card or entry is plain to see: it is what Alt+arrows will move. */
:is(.board-card, .cal-ev):focus-visible {
  outline: 2px solid var(--app-accent-tone);
  outline-offset: 2px;
}

/* Focus is always plain to see, also on the quiet controls (row actions,
   the day numbers of the calendar, a dialog's close button). */
td.actions :is(button, [role="button"], a):focus-visible,
.cal-daynum:focus-visible,
dialog > article > header > [rel="prev"]:focus-visible,
.nav-close:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--app-accent-tone);
  outline-offset: 2px;
}

/* --- pagination (partials/pagination.html) -----------------------------------
   Under a list, three places: on the left how many rows per page (when
   offered), in the middle the pages, on the right which rows are shown. */
.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  color: var(--app-muted);
  font-size: 0.9rem;
}

.pagination-size label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.pagination-size select {
  width: auto;
  height: 2.25rem;
  min-height: 0;
  margin: 0;
  padding-block: 0;
  font-size: inherit;
}

.pagination-range {
  justify-self: end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pagination-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

/* A narrow screen: the pages take a row of their own, the other two share the next. */
@media (max-width: 640px) {
  .pagination {
    grid-template-columns: 1fr auto;
  }

  .pagination-pages {
    grid-column: 1 / -1;
    grid-row: 1;
  }
}

.pagination-pages button {
  --btn-bg: transparent;
  --btn-hover: var(--app-subtle);
  --btn-color: var(--app-text);
  min-width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0 0.5rem;
  border-color: transparent;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pagination-pages button:hover:not(:disabled) {
  border-color: var(--app-border);
}

.pagination-pages button[aria-current="page"] {
  --btn-bg: var(--app-accent-tone);
  --btn-hover: var(--app-accent-tone);
  --btn-color: var(--app-on-accent);
  border-color: var(--app-accent-tone);
  font-weight: 600;
  cursor: default;
}

.pagination-pages .pagination-step {
  font-size: 1.25rem;
  border-color: var(--app-border);
}

.pagination-pages button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination-gap {
  min-width: 1.5rem;
  color: var(--app-muted);
  text-align: center;
}

/* A choice with its explanation under the name (the Security page's session presets). */
label.session-policy {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

label.session-policy input {
  margin-top: 0.25rem;
}

label.session-policy span {
  display: grid;
}

/* A user's page: who they are, then their sections side by side (one column on a phone). */
.user-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

.user-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

.user-head p {
  margin: 0.2rem 0 0;
}

.user-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.user-tags:not(:empty) {
  margin-top: 0.6rem !important;
}

.user-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--app-space);
  margin-bottom: var(--app-space);
}

.user-sections > article {
  margin: 0;
}

.user-sections > article > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.4rem;
  padding-block: 0.5rem;
}

.user-sections h2 {
  margin: 0;
  font-size: 1rem;
}

.user-sections header button {
  padding: 0.2rem 0.65rem;
  font-size: 0.85rem;
}

.user-sections dl.facts {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* Permission checkboxes (roles, access): columns as wide as a long name needs, as many as fit,
   each box beside its name. */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  align-items: start;
  gap: 0.35rem 1rem;
}

.perm-grid > label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.perm-grid > label > input {
  flex: none;
  margin: 0;
}

/* What a permission allows, under its name (not for read, create, update, delete). */
.perm-grid > label:has(small) {
  align-items: flex-start;
}

.perm-grid > label:has(small) > input {
  margin-top: 0.2rem;
}

.perm-grid > label small {
  display: block;
  margin-top: 0.1rem;
  color: var(--app-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* Audit log (audit/list.html): a status per entry */
.audit-status {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--app-subtle);
  color: var(--app-muted);
}

.audit-status.is-ok {
  background: var(--app-success-soft);
  color: var(--app-success);
}

.audit-status.is-denied,
.audit-status.is-error {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

.audit-status.is-not_found,
.audit-status.is-invalid {
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

/* Connecting an AI assistant (mcp/consent.html) */
.ai-consent {
  max-width: 36rem;
  margin: 2rem auto;
}

.ai-consent .rows li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--app-space);
}

.badge-tool {
  flex: 0 0 auto;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--app-subtle);
  color: var(--app-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge-tool.is-changes {
  background: var(--app-warning-soft);
  color: var(--app-warning);
}

/* The account's AI assistant permissions (mcp/permissions.html): a switch per tool, then the tool in words */
.ai-tool-list label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0;
}

.ai-tool-list label > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.ai-tool-list label small.muted {
  flex-basis: 100%;
}

/* The switch beside the tool's name, on its line. */
.ai-tool-list input[role="switch"] {
  flex: 0 0 auto;
  margin-top: 0.2rem;
}

.badge-tool.is-destructive {
  background: var(--app-danger-soft);
  color: var(--app-danger);
}

/* A record's state and its steps (partials/workflow.html). */
.workflow { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.workflow .tag { font-size: 0.85rem; }
.workflow button, .workflow summary[role="button"] { margin: 0; }
.workflow-note { position: relative; margin: 0; }
.workflow-note > summary { list-style: none; cursor: pointer; }
.workflow-note[open] > form { position: absolute; z-index: 5; top: calc(100% + 0.4rem); left: 0; width: min(22rem, 80vw);
  padding: 0.75rem; border: 1px solid var(--app-border); border-radius: var(--app-radius); background: var(--app-surface);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); }

/* Key figures on a dashboard (partials/stats.html). */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--app-space); margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 1.1rem; border: 1px solid var(--app-border);
  border-radius: var(--app-radius); background: var(--app-surface); color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--app-accent-tone); }
.stat-label { color: var(--app-muted); font-size: 0.88rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-change { font-size: 0.85rem; font-weight: 600; }
.stat-change small { font-weight: 400; color: var(--app-muted); }
.stat-change.is-good { color: var(--app-success, #15803d); }
.stat-change.is-bad { color: var(--app-danger, #b91c1c); }
.stat-trend { height: 2.2rem; margin-top: 0.25rem; }
.stat-trend svg { width: 100%; height: 100%; }

/* The customer portal's head (layouts/portal.html). */
.portal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--app-border); }
.portal-brand { display: inline-flex; align-items: center; gap: 0.5rem; color: inherit; text-decoration: none; }
.portal-who { display: inline-flex; align-items: center; gap: 0.75rem; color: var(--app-muted); }
.portal-who button { margin: 0; }

/* The field only programs fill in (partials/public_form.html): off screen, not display:none (some bots skip those). */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
