/* ==========================================================================
   Tabla - design system
   Two typefaces: Instrument Sans (interface) and JetBrains Mono (numbers that
   are read as codes: due days, tax numbers, amounts). Colour carries meaning
   in exactly one place - the status of a task (done / in progress / due soon
   / overdue / waiting) - and every status also has its own icon, so nothing
   depends on colour alone. The status cell of the board is the product's
   signature element.
   ========================================================================== */

/* --- Fonts (self-hosted, OFL) -------------------------------------------- */
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/instrument-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* --- Tokens --------------------------------------------------------------- */
:root {
  color-scheme: light;

  --canvas: #f1f4f9;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --ink: #16202f;
  --muted: #556277;
  --line: #d7deea;
  --line-strong: #b5c0d2;

  --brand: #1d4f91;
  --brand-strong: #153a6d;
  --brand-tint: #e3ecf9;
  --on-brand: #ffffff;

  --ok: #1c6630;
  --ok-tint: #e1f3e3;
  --ok-line: #9fd3a8;
  --warn: #855000;
  --warn-tint: #fdf0d5;
  --warn-line: #e8c47a;
  --danger: #b3261e;
  --danger-strong: #8f1d17;
  --danger-tint: #fcebe9;
  --danger-line: #eeaaa4;
  --info: #1b57b5;
  --info-tint: #e6eefb;
  --info-line: #a9c4ee;

  --nav-bg: #10233d;
  --nav-ink: #c2cfe1;
  --nav-ink-strong: #ffffff;
  --nav-hover: #193152;
  --nav-active: #213f69;
  --nav-accent: #8fd16a;

  --focus: #1b57b5;
  --shadow-1: 0 1px 2px rgb(16 32 58 / 6%), 0 1px 1px rgb(16 32 58 / 4%);
  --shadow-2: 0 10px 30px rgb(16 32 58 / 16%), 0 2px 6px rgb(16 32 58 / 8%);

  --font-ui: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1.0625rem;
  --text-lg: 1.3125rem;
  --text-xl: 1.625rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-width: 14rem;
  --header-height: 3.75rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --canvas: #0c121b;
  --surface: #151d2a;
  --surface-2: #1a2433;
  --ink: #e6ebf3;
  --muted: #9aa8bc;
  --line: #283446;
  --line-strong: #3b4a61;

  --brand: #82b3f2;
  --brand-strong: #aacbf7;
  --brand-tint: #16294a;
  --on-brand: #06182e;

  --ok: #78d694;
  --ok-tint: #12301c;
  --ok-line: #2c6a3d;
  --warn: #f0b955;
  --warn-tint: #352a12;
  --warn-line: #7a5f22;
  --danger: #ff8f86;
  --danger-strong: #ffb0a9;
  --danger-tint: #3a1a18;
  --danger-line: #7d3530;
  --info: #8ab6f5;
  --info-tint: #16273f;
  --info-line: #345b93;

  --nav-bg: #090f18;
  --nav-hover: #141e2c;
  --nav-active: #1a2940;

  --focus: #8ab6f5;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-2: 0 12px 32px rgb(0 0 0 / 55%);
}

/* --- Base ----------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-xl);
}

h2 {
  font-size: var(--text-md);
}

h3 {
  font-size: var(--text-base);
}

p {
  margin: 0 0 0.75rem;
}

a {
  color: var(--brand);
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--brand-strong);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--brand);
  color: var(--on-brand);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-feature-settings: "zero" 1;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: var(--text-sm);
}

.nowrap {
  white-space: nowrap;
}

.break {
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 1.75rem;
  height: 1.75rem;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  top: 0.5rem;
  color: var(--on-brand);
}

/* --- App shell ------------------------------------------------------------ */
.shell {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
  color: var(--nav-ink);
  padding: 0 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  padding-left: calc(0.75rem + env(safe-area-inset-left));
  transform: translateX(-100%);
  /* visibility keeps the closed drawer out of the tab order on small screens */
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0.2s;
  overflow-y: auto;
}

.sidebar.is-open {
  transform: none;
  visibility: visible;
  box-shadow: var(--shadow-2);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(8 14 20 / 55%);
  border: 0;
  padding: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: var(--header-height);
  padding: 0 0.5rem;
  color: var(--nav-ink-strong);
  font-weight: 650;
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  text-decoration: none;
  flex: none;
}

.brand:hover {
  color: var(--nav-ink-strong);
}

.brand-mark {
  width: 1.9rem;
  height: 1.9rem;
  flex: none;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.nav-label {
  margin: 1.1rem 0.6rem 0.35rem;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8fa0af;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 2.75rem;
  padding: 0 0.7rem;
  border-radius: var(--radius-sm);
  color: var(--nav-ink);
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover {
  background: var(--nav-hover);
  color: var(--nav-ink-strong);
}

.nav a[aria-current="page"] {
  background: var(--nav-active);
  color: var(--nav-ink-strong);
  box-shadow: inset 3px 0 0 var(--nav-accent);
}

.nav a[aria-current="page"] .icon {
  color: var(--nav-accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 1rem 0.6rem 0.25rem;
  font-size: var(--text-xs);
  color: #8fa0af;
}

.env-tag {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid #3a4a59;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: #d9c07a;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--header-height);
  padding: 0 0.75rem;
  padding-left: calc(0.75rem + env(safe-area-inset-left));
  padding-right: calc(0.75rem + env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.main {
  padding: 1.25rem 0.75rem calc(3rem + env(safe-area-inset-bottom));
  padding-left: calc(0.75rem + env(safe-area-inset-left));
  padding-right: calc(0.75rem + env(safe-area-inset-right));
  max-width: 82rem;
  margin: 0 auto;
}

@media (min-width: 64rem) {
  .sidebar {
    transform: none;
    visibility: visible;
  }

  .sidebar-backdrop,
  .menu-toggle {
    display: none !important;
  }

  .shell-body {
    margin-left: var(--sidebar-width);
  }

  .topbar {
    padding: 0 1.75rem;
  }

  .main {
    padding: 1.75rem 1.75rem 4rem;
  }
}

/* --- Quick search --------------------------------------------------------- */
.search {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 34rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.75rem;
  padding: 0 0.75rem;
  background: var(--canvas);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
}

.search-box:focus-within {
  background: var(--surface);
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.search-box input::placeholder {
  color: var(--muted);
}

.kbd {
  display: none;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (min-width: 48rem) {
  .kbd {
    display: inline-block;
  }
}

.search-results {
  position: absolute;
  inset: calc(100% + 0.4rem) 0 auto 0;
  z-index: 50;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  max-height: min(26rem, 70dvh);
  overflow-y: auto;
}

.search-results a,
.search-note {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
}

.search-results a.is-active,
.search-results a:hover {
  background: var(--brand-tint);
}

.search-results .result-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.search-results .result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.75rem;
  font-size: var(--text-sm);
  color: var(--muted);
}

.search-note {
  color: var(--muted);
  font-size: var(--text-sm);
}

.search-all {
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  font-weight: 600;
  color: var(--brand) !important;
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--muted);
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--on-brand);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .btn-danger {
  color: #2a0d0b;
}

.btn-danger:hover {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: var(--canvas);
  border-color: transparent;
}

.btn-danger-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-tint);
  border-color: transparent;
  color: var(--danger);
}

.btn-icon {
  width: 2.75rem;
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.inline-form {
  display: inline;
}

/* --- Page header ---------------------------------------------------------- */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.page-head .lead {
  margin: 0.3rem 0 0;
  color: var(--muted);
  max-width: 46rem;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--muted);
}

.crumbs li + li::before {
  content: "/";
  margin-right: 0.35rem;
  color: var(--line-strong);
}

/* --- Cards ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}

.card + .card,
.stack > * + * {
  margin-top: 1rem;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.card-body {
  padding: 1.1rem;
}

.card-foot {
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 60rem) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-main {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    align-items: start;
  }
}

/* --- Stat tiles ----------------------------------------------------------- */
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 48rem) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 75rem) {
  .stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.stat {
  display: block;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  text-decoration: none;
}

a.stat:hover {
  border-color: var(--brand);
  color: var(--ink);
}

.stat-label {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
}

.stat-value {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--text-xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* --- Badges and identifier chips ------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--canvas);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
}

.badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.badge-plain::before {
  display: none;
}

.badge-ok {
  background: var(--ok-tint);
  color: var(--ok);
  border-color: transparent;
}

.badge-warn {
  background: var(--warn-tint);
  color: var(--warn);
  border-color: transparent;
}

.badge-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border-color: transparent;
}

.badge-info {
  background: var(--info-tint);
  color: var(--info);
  border-color: transparent;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  min-height: 1.75rem;
  padding: 0.1rem 0.5rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-feature-settings: "zero" 1;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
}

.chip:hover {
  border-style: solid;
  border-color: var(--brand);
}

.chip .icon {
  width: 0.85rem;
  height: 0.85rem;
  color: var(--muted);
}

.chip.is-copied {
  border-style: solid;
  border-color: var(--ok);
  background: var(--ok-tint);
  color: var(--ok);
}

.chip-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 600;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.monogram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  background: var(--brand-tint);
  color: var(--brand-strong);
}

.monogram-lg {
  width: 3.25rem;
  height: 3.25rem;
  font-size: var(--text-md);
  border-radius: var(--radius);
}

.tone-1 { background: var(--brand-tint); color: var(--brand-strong); }
.tone-2 { background: var(--info-tint); color: var(--info); }
.tone-3 { background: var(--warn-tint); color: var(--warn); }
.tone-4 { background: var(--ok-tint); color: var(--ok); }
.tone-5 { background: var(--danger-tint); color: var(--danger); }
.tone-6 { background: var(--canvas); color: var(--muted); }

/* --- Alerts --------------------------------------------------------------- */
.alert {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--info-tint);
  color: var(--ink);
}

.alert .icon {
  margin-top: 0.15rem;
  color: var(--info);
}

.alert-body {
  flex: 1;
  min-width: 0;
}

.alert-body > :last-child {
  margin-bottom: 0;
}

.alert-success {
  background: var(--ok-tint);
}

.alert-success .icon {
  color: var(--ok);
}

.alert-error {
  background: var(--danger-tint);
}

.alert-error .icon {
  color: var(--danger);
}

.alert-warning {
  background: var(--warn-tint);
}

.alert-warning .icon {
  color: var(--warn);
}

.alert-close {
  margin: -0.35rem -0.4rem -0.35rem 0;
  min-height: 2.25rem;
  width: 2.25rem;
}

.alert ul {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

/* --- Tables --------------------------------------------------------------- */
.table-wrap {
  position: relative;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.table th,
.table td {
  padding: 0.7rem 1.1rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr[data-href] {
  cursor: pointer;
}

.table tbody tr[data-href]:hover {
  background: var(--surface-2);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.75rem;
  color: inherit;
  text-decoration: none;
}

.sort-link:hover {
  color: var(--ink);
}

.sort-link .icon {
  width: 0.8rem;
  height: 0.8rem;
  opacity: 0.35;
}

th[aria-sort="ascending"] .sort-link,
th[aria-sort="descending"] .sort-link {
  color: var(--ink);
}

th[aria-sort] .sort-link .icon {
  opacity: 1;
  color: var(--brand);
}

th[aria-sort="descending"] .sort-link .icon {
  transform: rotate(180deg);
}

.cell-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.cell-main a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.cell-main a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.cell-sub {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Below 48rem a table turns into a list of cards: one row = one card,
   each cell labelled by its column header (data-label). */
@media (max-width: 47.99rem) {
  .table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    width: 100%;
  }

  .table-stack tr {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
  }

  .table-stack tbody tr:last-child {
    border-bottom: 0;
  }

  .table-stack td {
    display: grid;
    grid-template-columns: 8.5rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.2rem 0;
    border: 0;
    text-align: left;
  }

  .table-stack td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    padding-top: 0.2rem;
  }

  .table-stack td.cell-title {
    display: block;
    padding-bottom: 0.4rem;
  }

  .table-stack td.cell-title::before,
  .table-stack td.actions::before {
    display: none;
  }

  .table-stack td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding-top: 0.5rem;
    text-align: left;
  }

  .table-stack .num {
    text-align: left;
  }
}

/* --- Filters / toolbar ---------------------------------------------------- */
.toolbar {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

@media (min-width: 48rem) {
  .toolbar {
    grid-template-columns: minmax(12rem, 2fr) repeat(auto-fit, minmax(9rem, 1fr));
    align-items: end;
  }

  .toolbar .toolbar-actions {
    grid-column: 1 / -1;
  }
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.result-count {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* --- Forms ---------------------------------------------------------------- */
.form-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 48rem) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-grid .field-wide {
    grid-column: 1 / -1;
  }
}

.field {
  min-width: 0;
}

.label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: var(--text-sm);
  font-weight: 600;
}

.label .req {
  color: var(--danger);
  margin-left: 0.15rem;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  /* 16px on small screens keeps iOS from zooming into the field. */
  font-size: 1rem;
}

@media (min-width: 48rem) {
  .input,
  .select,
  .textarea {
    font-size: var(--text-base);
  }
}

.input.mono,
.textarea.mono {
  font-family: var(--font-mono);
  font-feature-settings: "zero" 1;
}

.textarea {
  min-height: 6.5rem;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.75rem) 50%;
  background-size: 0.3rem 0.3rem;
  background-repeat: no-repeat;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.help {
  margin: 0.3rem 0 0;
  font-size: var(--text-sm);
  color: var(--muted);
}

.error {
  display: flex;
  gap: 0.35rem;
  margin: 0.3rem 0 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--danger);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.6rem 0;
  cursor: pointer;
}

.check input {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0.15rem 0 0;
  flex: none;
  accent-color: var(--brand);
}

.check-text small {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

.fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.fieldset legend {
  padding: 0;
  margin-bottom: 0.3rem;
  font-size: var(--text-sm);
  font-weight: 600;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.form-narrow {
  max-width: 34rem;
}

/* --- Tabs ----------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0 0 1rem;
  padding: 0 0 1px;
  list-style: none;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}

.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 0.85rem;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-count {
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--canvas);
  font-size: var(--text-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --- Partner header ------------------------------------------------------- */
.entity {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.entity-id {
  display: flex;
  gap: 0.9rem;
  min-width: 0;
  flex: 1 1 20rem;
}

.entity-title {
  font-size: var(--text-lg);
  overflow-wrap: anywhere;
}

.entity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
  align-items: center;
}

/* --- Definition list ------------------------------------------------------ */
.dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.dl > div {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.dl > div:last-child {
  border-bottom: 0;
}

.dl dt {
  color: var(--muted);
  font-size: var(--text-sm);
  padding-top: 0.1rem;
}

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

.prewrap {
  white-space: pre-wrap;
}

/* --- Item list (contacts / addresses / accounts) -------------------------- */
.items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.item:last-child {
  border-bottom: 0;
}

.item.is-inactive .item-body {
  opacity: 0.7;
}

.item-body {
  display: flex;
  gap: 0.8rem;
  min-width: 0;
  flex: 1 1 18rem;
}

.item-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.item-lines {
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--muted);
}

.item-lines li {
  overflow-wrap: anywhere;
}

.item-lines a {
  color: inherit;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

/* --- Timeline (history) --------------------------------------------------- */
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.event {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.event:last-child {
  border-bottom: 0;
}

.event-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  align-items: baseline;
  justify-content: space-between;
}

.event-title {
  font-weight: 600;
}

.event-meta {
  font-size: var(--text-sm);
  color: var(--muted);
}

.changes {
  width: 100%;
  margin-top: 0.5rem;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.changes th,
.changes td {
  padding: 0.3rem 0.5rem 0.3rem 0;
  text-align: left;
  vertical-align: top;
  border-top: 1px dashed var(--line);
  overflow-wrap: anywhere;
}

.changes th {
  width: 9.5rem;
  font-weight: 500;
  color: var(--muted);
}

.changes .old {
  color: var(--danger);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--danger) 50%, transparent);
}

.changes .new {
  color: var(--ok);
}

.changes .arrow {
  color: var(--muted);
  padding: 0 0.25rem;
}

/* --- Empty state ---------------------------------------------------------- */
.empty {
  padding: 2.5rem 1.25rem;
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: 0.75rem;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand);
}

.empty h2,
.empty h3 {
  font-size: var(--text-md);
}

.empty p {
  max-width: 30rem;
  margin: 0.4rem auto 1rem;
  color: var(--muted);
}

/* --- Pagination ----------------------------------------------------------- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--muted);
}

.pages {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pages a,
.pages span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pages a:hover {
  background: var(--canvas);
}

.pages [aria-current="page"] {
  background: var(--brand);
  color: var(--on-brand);
}

.pages .gap {
  color: var(--muted);
  min-width: 1.5rem;
}

/* --- User menu ------------------------------------------------------------ */
.menu {
  position: relative;
  margin-left: auto;
}

.menu > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0 0.4rem;
  border-radius: var(--radius-sm);
  list-style: none;
  cursor: pointer;
  font-weight: 600;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary:hover {
  background: var(--canvas);
}

.menu-name {
  display: none;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 48rem) {
  .menu-name {
    display: inline;
  }
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 50;
  min-width: 15rem;
  padding: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}

.menu-who {
  padding: 0.5rem 0.65rem 0.65rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.3rem;
}

.menu-panel a,
.menu-panel button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0 0.65rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu-panel a:hover,
.menu-panel button:hover {
  background: var(--canvas);
}

/* --- Dialog --------------------------------------------------------------- */
.dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}

.dialog::backdrop {
  background: rgb(8 14 20 / 55%);
}

.dialog-body {
  padding: 1.25rem 1.25rem 0.5rem;
}

.dialog-body h2 {
  margin-bottom: 0.5rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 0.75rem 1.25rem 1.25rem;
}

/* --- Auth pages ----------------------------------------------------------- */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.auth-card {
  width: 100%;
  max-width: 25rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.auth-brand .brand-mark {
  width: 2.25rem;
  height: 2.25rem;
}

.auth-foot {
  margin-top: 1rem;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* --- Code / docs ---------------------------------------------------------- */
.code {
  display: block;
  margin: 0.5rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--nav-bg);
  color: #dbe5ec;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: var(--canvas);
}

.code code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.method {
  display: inline-block;
  min-width: 3.6rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  background: var(--info-tint);
  color: var(--info);
}

.method-post {
  background: var(--ok-tint);
  color: var(--ok);
}

.method-patch {
  background: var(--warn-tint);
  color: var(--warn);
}

.token-box {
  padding: 1rem;
  border: 2px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-tint);
  margin-bottom: 1rem;
}

.token-value {
  display: block;
  margin: 0.6rem 0;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  user-select: all;
}

.codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 1rem;
  margin: 0.6rem 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
}

.qr {
  display: inline-block;
  padding: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 0;
}

.qr svg {
  width: 11.5rem;
  height: 11.5rem;
}

.prose h2 {
  margin: 1.5rem 0 0.5rem;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose ul,
.prose ol {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.25rem;
}

.compare {
  display: grid;
  gap: 1rem;
}

@media (min-width: 48rem) {
  .compare {
    grid-template-columns: 1fr auto 1fr;
    align-items: stretch;
  }
}

.compare-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.subnav a[aria-current="page"] {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.skeleton {
  display: block;
  height: 2.6rem;
  margin: 0.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--canvas) 25%, var(--line) 50%, var(--canvas) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 1rem; }
.text-right { text-align: right; }
.grow { flex: 1; }

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

@media print {
  .sidebar,
  .topbar,
  .btn,
  .tabs,
  .pagination {
    display: none !important;
  }

  .shell-body {
    margin: 0;
  }
}

/* ==========================================================================
   Tabla - product-specific components
   ========================================================================== */

/* --- Shell additions ------------------------------------------------------ */
.main-wide {
  max-width: none;
}

.nav a > span:first-of-type {
  flex: 1;
  min-width: 0;
}

.nav-count {
  flex: none;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: #ffb84d;
  color: #2b1a00;
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
}

.nav-help {
  margin-top: 1.1rem;
}

.bell {
  position: relative;
  flex: none;
}

.bell.has-due {
  color: var(--danger);
}

.bell-count {
  position: absolute;
  top: 0.3rem;
  right: 0.2rem;
  min-width: 1.15rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.15rem;
  text-align: center;
}

:root[data-theme="dark"] .bell-count {
  color: #2a0d0b;
}

/* --- Small controls -------------------------------------------------------- */
.btn-sm {
  min-height: 2.25rem;
  padding: 0 0.7rem;
  font-size: var(--text-sm);
}

/* Small buttons keep a 44px touch target on coarse pointers. */
@media (pointer: coarse) {
  .btn-sm {
    min-height: 2.75rem;
  }
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.select-sm {
  min-height: 2.25rem;
  width: auto;
  padding-top: 0;
  padding-bottom: 0;
  font-size: var(--text-sm);
}

.input-xs {
  width: 4.5rem;
  min-height: 2.25rem;
  text-align: center;
  font-family: var(--font-mono);
}

.input-code {
  max-width: 11rem;
  font-size: var(--text-lg);
  letter-spacing: 0.2em;
  text-align: center;
}

.num {
  font-variant-numeric: tabular-nums;
}

.form-medium {
  max-width: 46rem;
}

.form-wide {
  max-width: 62rem;
}

.field-end {
  display: flex;
  align-items: flex-end;
}

@media (min-width: 48rem) {
  .form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form-grid-4 {
    grid-template-columns: 2fr 2fr 1fr auto;
  }
}

.time-range {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.time-range .input {
  flex: 1;
  min-width: 0;
}

.inline-edit {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.snooze {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
}

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

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin-top: 1rem;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--canvas) 70%, transparent);
}

.card-note {
  margin: 0;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-sm);
}

.item-compact {
  padding: 0.7rem 1.1rem;
  align-items: center;
}

.item-compact .item-body {
  display: flex;
  flex-direction: column;
}

a.item-title {
  color: var(--ink);
  text-decoration: none;
}

a.item-title:hover {
  color: var(--brand);
  text-decoration: underline;
}

.table-compact th,
.table-compact td {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.table tr.is-muted td {
  color: var(--muted);
}

.table tfoot th,
.table tfoot td {
  padding: 0.7rem 1.1rem;
  border-top: 2px solid var(--line-strong);
  text-align: left;
}

.table tfoot td.text-right {
  text-align: right;
}

.col-check {
  width: 2.75rem;
}

.col-check input,
.table input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--brand);
}

.tab-count-new {
  background: var(--danger);
  color: #fff;
}

:root[data-theme="dark"] .tab-count-new {
  color: #2a0d0b;
}

.kbd-inline {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.stats-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 60rem) {
  .stats-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.steps {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

/* --- Status vocabulary ------------------------------------------------------
   One mapping, used by the board cells, the summary pills, the "my open
   tasks" strip, the cell panel and the legend in the help page. */
.status-done {
  --st-bg: var(--ok-tint);
  --st-fg: var(--ok);
  --st-line: var(--ok-line);
}

.status-overdue {
  --st-bg: var(--danger-tint);
  --st-fg: var(--danger);
  --st-line: var(--danger-line);
}

.status-soon {
  --st-bg: var(--warn-tint);
  --st-fg: var(--warn);
  --st-line: var(--warn-line);
}

.status-progress {
  --st-bg: var(--info-tint);
  --st-fg: var(--info);
  --st-line: var(--info-line);
}

.status-pending {
  --st-bg: var(--surface);
  --st-fg: var(--muted);
  --st-line: var(--line-strong);
}

.status-badge {
  background: var(--st-bg);
  color: var(--st-fg);
  border-color: var(--st-line);
}

/* --- Board: header and summary -------------------------------------------- */
.board-head {
  align-items: center;
}

.period-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.period-label {
  min-width: 9.5rem;
  padding: 0 0.35rem;
  font-size: var(--text-md);
  text-align: center;
  text-transform: capitalize;
}

.status-pills {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .status-pills {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.status-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.55rem;
  align-items: center;
  min-height: 3.6rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--st-line);
  border-left: 5px solid var(--st-fg);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-1);
}

.status-pill .icon {
  grid-row: 1 / 3;
  width: 1.4rem;
  height: 1.4rem;
  color: var(--st-fg);
}

.status-pill:hover {
  background: var(--st-bg);
  color: var(--ink);
}

.status-pill.is-active {
  background: var(--st-bg);
  box-shadow: 0 0 0 2px var(--st-fg);
}

.status-count {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.status-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* --- Board: layout ---------------------------------------------------------
   The matrix needs width. Three arrangements:
   - narrow:  dates (list), matrix, the other cards
   - medium:  dates as one horizontal strip above the matrix, the other cards below
   - very wide: dates and the other cards in a rail to the right of the matrix */
.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "dates"
    "main"
    "aside";
  gap: 1rem;
  align-items: start;
}

.board-layout > .card + .card,
.board-layout > * {
  margin-top: 0;
}

.board-dates {
  grid-area: dates;
  min-width: 0;
}

.board-main {
  grid-area: main;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.board-main > .card + .card {
  margin-top: 0;
}

.board-aside {
  grid-area: aside;
  min-width: 0;
  display: grid;
  gap: 1rem;
  align-items: start;
}

.board-aside > .card + .card {
  margin-top: 0;
}

.board-dates .card-head h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.board-dates .card-head .icon {
  color: var(--brand);
}

@media (min-width: 48rem) and (max-width: 99.99rem) {
  .board-layout .board-aside {
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  }
}

@media (min-width: 48rem) {

  /* Strip: the next dates side by side, scrolling sideways if they do not fit. */
  .board-dates .date-list {
    position: relative;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(15.5rem, 1fr);
    overflow-x: auto;
    scrollbar-width: thin;
  }

  .board-dates .date-item {
    border-bottom: 0;
    border-right: 1px solid var(--line);
    padding: 0.55rem 0.75rem;
  }

  .board-dates .date-body > * {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .board-dates .date-body .muted {
    display: none;
  }

  .board-dates .date-body .date-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    white-space: normal;
  }

  .board-dates .date-partner {
    display: none;
  }

  .board-dates .card-head {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .board-dates .date-item:last-child {
    border-right: 0;
  }
}

@media (min-width: 100rem) {
  .board-layout.has-rail {
    grid-template-columns: minmax(0, 1fr) 21rem;
    grid-template-areas:
      "main dates"
      "main aside";
    grid-template-rows: auto 1fr;
  }

  .board-aside {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-dates .date-list {
    display: block;
    overflow: visible;
  }

  .board-dates .date-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.65rem 0.9rem;
  }

  .board-dates .date-body > * {
    white-space: normal;
  }

  .board-dates .date-body .muted {
    display: inline;
  }

  .board-dates .date-body .date-title {
    display: inline;
  }

  .board-dates .date-partner {
    display: block;
  }

  .board-dates .card-head {
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
  }

  .board-dates .date-item:last-child {
    border-bottom: 0;
  }
}

.board-aside .card-head h2 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.board-aside .card-head .icon {
  color: var(--brand);
}

.board-aside .card-foot {
  padding: 0.6rem 0.75rem 0.75rem;
  border-top: 1px solid var(--line);
}

.aside-empty {
  margin: 0;
  padding: 0.9rem 1.1rem 1.1rem;
  color: var(--muted);
  font-size: var(--text-sm);
}

.board-toolbar {
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (min-width: 48rem) {
  .toolbar.board-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
  }

  .board-toolbar .field {
    flex: 1 1 8.5rem;
    min-width: 0;
    max-width: 15rem;
  }

  .toolbar.board-toolbar .toolbar-actions {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    border: 0;
  }
}

/* --- Board: my open tasks --------------------------------------------------- */
.my-open-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
  list-style: none;
}


.my-open-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 3.25rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--st-line);
  border-left: 4px solid var(--st-fg);
  border-radius: var(--radius-sm);
  background: var(--st-bg);
  color: var(--ink);
  text-decoration: none;
}

.my-open-item:hover {
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--st-fg);
}

.my-open-item .icon {
  color: var(--st-fg);
}

.my-open-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.my-open-text strong,
.my-open-text .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-open-text .muted {
  font-size: var(--text-sm);
}

.my-open-due {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--st-fg);
  line-height: 1.2;
}

.my-open-due small {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--text-xs);
}

/* --- Board: the matrix ------------------------------------------------------ */
.matrix-wrap {
  position: relative;
  overflow: auto;
  max-height: calc(100dvh - 9rem);
  border-top: 1px solid var(--line);
}

.matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  min-width: 3.85rem;
  padding: 0.5rem 0.2rem;
  background: var(--surface-2);
  vertical-align: bottom;
  text-align: center;
  font-weight: 600;
}

.matrix-code {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--brand);
}

.matrix-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  font-size: var(--text-xs);
  line-height: 1.2;
  color: var(--muted);
  font-weight: 500;
}

.matrix .matrix-partner {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 11rem;
  min-width: 10rem;
  max-width: 15rem;
  padding: 0.45rem 0.75rem;
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.matrix thead .matrix-partner {
  z-index: 4;
  background: var(--surface-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.matrix tbody tr:hover .matrix-partner {
  background: var(--brand-tint);
}

.matrix-partner a {
  color: var(--ink);
  text-decoration: none;
}

.matrix-partner a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.matrix-over {
  display: block;
  margin-top: 0.1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--danger);
}

.cell {
  padding: 0.2rem;
  height: 3.25rem;
  text-align: center;
  background: var(--surface);
}

/* Unassigned: hatched, so "nobody does this" reads differently from "waiting". */
.cell-none {
  background: repeating-linear-gradient(135deg, var(--canvas) 0 6px, var(--surface-2) 6px 12px);
}

.cell-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  height: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--st-line);
  border-radius: var(--radius-sm);
  background: var(--st-bg);
  color: var(--st-fg);
  text-decoration: none;
  line-height: 1.1;
}

.cell-link:hover,
.cell-link:focus-visible {
  color: var(--st-fg);
  box-shadow: 0 0 0 2px var(--st-fg);
}

.cell-link.is-mine {
  border-width: 2px;
  border-color: var(--st-fg);
}

.cell-link .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.cell-link.status-pending .icon {
  opacity: 0.5;
}

.cell-day {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
}

.cell-who {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.matrix-legend {
  margin: 0;
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Narrow screens: every partner becomes a card listing only its assigned
   tasks - a 13-column grid is unreadable at 360px. */
@media (max-width: 47.99rem) {
  .matrix-wrap {
    max-height: none;
    overflow: visible;
  }

  .matrix,
  .matrix tbody,
  .matrix tr,
  .matrix th,
  .matrix td {
    display: block;
    width: 100%;
  }

  .matrix thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .matrix th,
  .matrix td {
    border-right: 0;
  }

  .matrix tbody tr {
    padding: 0.5rem 0.75rem 0.75rem;
    border-bottom: 6px solid var(--canvas);
  }

  .matrix .matrix-partner {
    position: static;
    max-width: none;
    padding: 0.35rem 0 0.5rem;
    border-bottom: 0;
    font-size: var(--text-md);
    background: transparent;
  }

  .matrix tbody tr:hover .matrix-partner {
    background: transparent;
  }

  .cell-none {
    display: none !important;
  }

  .cell {
    height: auto;
    padding: 0.2rem 0;
    border-bottom: 0;
  }

  .cell-link {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.6rem;
    min-height: 2.9rem;
    padding: 0 0.75rem;
  }

  .cell-link::before {
    content: attr(title);
    order: 5;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: left;
  }

  .cell-who {
    order: 9;
  }
}

/* --- Board: cell panel (dialog or page) ------------------------------------- */
.dialog-panel {
  width: min(44rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}

.dialog-close {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  height: 0;
  padding: 0.4rem 0.4rem 0 0;
}

.dialog-panel [data-panel-body] {
  padding: 1.25rem;
}

.dialog-panel .panel-loading {
  display: grid;
  gap: 0.75rem;
  padding: 0.5rem 0 1rem;
}

.cell-panel {
  display: grid;
  gap: 1.1rem;
  max-width: 44rem;
}

.cell-panel-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding-right: 2.5rem;
}

.cell-panel-title {
  font-size: var(--text-lg);
}

.cell-panel-sub {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.status-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--st-line);
  border-radius: var(--radius);
  background: var(--st-bg);
  color: var(--st-fg);
}

.cell-facts {
  display: grid;
  gap: 0.5rem 1.5rem;
  margin: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

@media (min-width: 40rem) {
  .cell-facts {
    grid-template-columns: auto auto 1fr;
  }
}

.cell-facts dt {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.cell-facts dd {
  margin: 0.1rem 0 0;
  font-weight: 600;
}

.cell-panel h3 {
  margin-bottom: 0.5rem;
}

.cell-activities {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cell-activities li {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.cell-activities li:last-child {
  border-bottom: 0;
}

.cell-activity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
}

.cell-activity-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.cell-form {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.cell-form-actions {
  margin-top: 1rem;
}

.remind-box {
  padding: 0.25rem 0.85rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.remind-box > summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--brand);
}

.remind-box[open] {
  padding-bottom: 0.85rem;
}

.remind-box[open] > summary {
  margin-bottom: 0.35rem;
}

/* --- Important dates -------------------------------------------------------- */
.date-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.date-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--line);
}

.date-item:last-child {
  border-bottom: 0;
}

.date-list-full .date-item {
  padding: 0.8rem 1.1rem;
}

.date-item.is-today {
  background: var(--warn-tint);
}

.date-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid var(--line-strong);
  border-top: 5px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--surface);
  line-height: 1;
}

.date-item.is-today .date-badge {
  border-top-color: var(--warn);
}

.date-day {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 700;
}

.date-month {
  margin-top: -0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.date-body {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.date-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.date-meta,
.date-partner,
.date-note {
  display: block;
  font-size: var(--text-sm);
  color: var(--muted);
}

.date-when {
  font-weight: 600;
  color: var(--ink);
}

.date-partner a {
  color: var(--muted);
}

.date-actions {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}

.date-actions .badge::before {
  display: none;
}

.date-actions .badge .icon {
  width: 0.8rem;
  height: 0.8rem;
}

@media (max-width: 47.99rem) {
  .board-dates .date-item:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 39.99rem) {
  .date-list-full .date-item {
    flex-wrap: wrap;
  }

  .date-list-full .date-actions {
    width: 100%;
    justify-content: flex-start;
    padding-left: 3.65rem;
  }
}

/* --- Mini lists (side panel) ------------------------------------------------ */
.mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  border-bottom: 1px solid var(--line);
}

.mini-list li:last-child {
  border-bottom: 0;
}

.mini-list a {
  display: block;
  padding: 0.6rem 0.9rem;
  color: var(--ink);
  text-decoration: none;
}

.mini-list a:hover {
  background: var(--surface-2);
}

.mini-list li.is-due a {
  box-shadow: inset 4px 0 0 var(--danger);
}

.mini-when,
.mini-meta {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted);
}

.mini-list li.is-due .mini-when {
  color: var(--danger);
  font-weight: 600;
}

.mini-text {
  display: block;
  overflow-wrap: anywhere;
}

/* --- Reminders, notes, posts ------------------------------------------------ */
.reminder.is-due {
  box-shadow: inset 4px 0 0 var(--danger);
}

.note-text {
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.note {
  scroll-margin-top: 5rem;
}

.note.is-important {
  border-left: 5px solid var(--danger);
}

.note.is-closed {
  background: var(--surface-2);
}

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

.note-replies {
  margin: 1rem 0 0;
  padding: 0 0 0 1rem;
  list-style: none;
  border-left: 3px solid var(--line);
}

.note-replies li {
  padding: 0.6rem 0;
}

.note-replies li + li {
  border-top: 1px solid var(--line);
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.note-reply[open] {
  flex-basis: 100%;
}

.note-reply > summary,
.inline-details > summary {
  list-style: none;
  width: fit-content;
}

.note-reply > summary::-webkit-details-marker,
.inline-details > summary::-webkit-details-marker {
  display: none;
}

.note-reply form,
.inline-details form {
  margin-top: 0.75rem;
}

.inline-details {
  margin-top: 0.75rem;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.attachments li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.post.is-pinned {
  box-shadow: inset 4px 0 0 var(--info);
}

.mail-item > summary {
  cursor: pointer;
  list-style-position: outside;
}

.mail-item > summary .item-title {
  display: block;
}

.mail-body {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* --- Assignments ------------------------------------------------------------ */
.assign-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.assign-chips li {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.assign-task {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--brand);
}

.assign-user {
  font-weight: 600;
}

.assign-due {
  font-family: var(--font-mono);
  color: var(--muted);
}

.bulk-bar {
  margin: 0;
  padding: 1rem 1.1rem;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.bulk-bar legend {
  float: left;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0;
  font-weight: 650;
}

.bulk-bar .form-grid {
  clear: both;
}

/* --- Groups and permissions ------------------------------------------------- */
.perm-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

@media (min-width: 60rem) {
  .perm-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.perm-grid > .card + .card {
  margin-top: 0;
}

.perm-section {
  min-width: 0;
  margin: 0;
  padding: 0.5rem 1.1rem 0.75rem;
}

.perm-legend {
  padding: 0 0.4rem;
  font-weight: 650;
  font-size: var(--text-md);
}

.perm-all {
  border-bottom: 1px dashed var(--line);
  margin-bottom: 0.2rem;
}

.rights {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 60rem) {
  .rights {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.check-list {
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: flex;
  gap: 0.45rem;
  padding: 0.2rem 0;
  font-size: var(--text-sm);
}

.check-list .icon {
  margin-top: 0.15rem;
  color: var(--ok);
}

/* --- Help legend ------------------------------------------------------------ */
.legend {
  padding: 0;
  list-style: none;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0;
}

.legend-swatch {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--st-line);
  border-radius: var(--radius-sm);
  background: var(--st-bg);
  color: var(--st-fg);
}

/* --- Print (reports are printed / saved as PDF from the browser) ----------- */
.print-only {
  display: none;
}

.print-header {
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid #000;
  font-size: 0.95rem;
  line-height: 1.35;
}

@media print {
  .no-print,
  .subnav,
  .alert,
  .skip-link,
  .sidebar-backdrop {
    display: none !important;
  }

  .print-only {
    display: block !important;
  }

  body,
  .card,
  .stat {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .card {
    border: 0;
    break-inside: auto;
  }

  .table-stack thead {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
  }

  .table th,
  .table td {
    padding: 0.25rem 0.4rem;
    border-bottom: 1px solid #999;
  }

  .table tr {
    break-inside: avoid;
  }

  .stat {
    border: 1px solid #999;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }
}

/* --- Layout corrections for Tabla's markup --------------------------------- */
.grid > * {
  min-width: 0;
}

.grid > .card + .card {
  margin-top: 0;
}

.grid + .grid,
.card + .grid,
.grid + .card {
  margin-top: 1rem;
}

.entity {
  justify-content: flex-start;
  padding: 0.25rem 0 0;
}

.entity-body {
  flex: 1 1 20rem;
  min-width: 0;
}

.item-body {
  flex-direction: column;
  gap: 0.15rem;
}

.item-lines {
  margin-top: 0.25rem;
}

.table tbody th,
.table tfoot th {
  background: transparent;
  color: var(--ink);
  font-size: inherit;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.item-lines > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-right: 0.9rem;
}

.board-aside,
.my-open-list {
  grid-template-columns: minmax(0, 1fr);
}

.board-aside > * {
  min-width: 0;
}

/* --- Installer -------------------------------------------------------------- */
.setup {
  align-items: start;
  padding-top: 2.5rem;
}

.setup-card {
  width: min(52rem, 100%);
  max-width: none;
}

.setup-card .card + .card,
.setup-card .card + .btn {
  margin-top: 1rem;
}

.setup-card .btn-block {
  min-height: 3.25rem;
  font-size: var(--text-md);
}

/* --- Import from the old Tabla ---------------------------------------------- */
.btn-row-end {
  justify-content: flex-end;
}

.progress {
  height: 0.75rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--canvas);
  border: 1px solid var(--line);
}

.progress-bar {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width 0.3s ease;
}

.load-state {
  border-top: 1px solid var(--line);
}

.report {
  border-top: 1px solid var(--line);
}

.report > summary {
  padding: 0.7rem 1.1rem;
  cursor: pointer;
}

.report-text {
  margin: 0;
  padding: 0.5rem 1.1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.45;
  white-space: pre;
}

.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

details.advanced > summary {
  cursor: pointer;
  list-style: none;
}

details.advanced > summary::-webkit-details-marker {
  display: none;
}

details.advanced > summary h2::before {
  content: "▸ ";
  color: var(--muted);
}

details.advanced[open] > summary h2::before {
  content: "▾ ";
}

/* --- Client portal ---------------------------------------------------------
   The partner's own people: a top bar instead of the sidebar, the same
   tokens and components otherwise. */
.portal-body {
  min-height: 100dvh;
  background: var(--canvas);
}

.portal-top {
  background: var(--nav-bg);
  color: var(--nav-ink);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.portal-top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 0.75rem;
}

.portal-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.portal-brand > span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.portal-partner {
  font-weight: 500;
  color: var(--nav-ink);
}

.portal-top .menu-name {
  color: var(--nav-ink-strong);
}

.portal-top .menu > summary {
  color: var(--nav-ink-strong);
}

.portal-nav {
  border-top: 1px solid var(--nav-hover);
  overflow-x: auto;
}

.portal-nav ul {
  display: flex;
  gap: 0.15rem;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.3rem 0.5rem;
  list-style: none;
}

.portal-nav a {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.75rem;
  padding: 0 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--nav-ink);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.portal-nav a:hover {
  background: var(--nav-hover);
  color: var(--nav-ink-strong);
}

.portal-nav a[aria-current="page"] {
  background: var(--nav-active);
  color: var(--nav-ink-strong);
  box-shadow: inset 0 -3px 0 var(--nav-accent);
}

.portal-main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem 0.75rem calc(3rem + env(safe-area-inset-bottom));
  padding-left: calc(0.75rem + env(safe-area-inset-left));
  padding-right: calc(0.75rem + env(safe-area-inset-right));
}

.portal-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.portal-strip-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--info-line);
  border-radius: 999px;
  background: var(--info-tint);
  color: var(--info);
  font-weight: 600;
  text-decoration: none;
}

/* --- Conversation ---------------------------------------------------------- */
.chat-card {
  display: flex;
  flex-direction: column;
}

.chat-scroll {
  max-height: min(60dvh, 34rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-day {
  align-self: center;
  margin: 0.4rem 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.chat-day span {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.chat-msg {
  display: flex;
  max-width: min(85%, 40rem);
}

.chat-mine {
  align-self: flex-end;
}

.chat-bubble {
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-lg);
  border-top-left-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.chat-mine .chat-bubble {
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-sm);
  background: var(--brand-tint);
  border-color: color-mix(in srgb, var(--brand) 25%, transparent);
}

.chat-meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.2rem;
  font-size: var(--text-xs);
  color: var(--muted);
}

.chat-text {
  white-space: pre-line;
}

.chat-file {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.4rem;
  font-weight: 600;
}

.chat-compose {
  padding: 0.8rem 1.1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.chat-compose textarea {
  resize: vertical;
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.chat-actions .help {
  flex: 1 1 8rem;
  margin: 0;
}

.chat-attach {
  cursor: pointer;
}

.chat-attach:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Shared to-do list ----------------------------------------------------- */
.todo {
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line);
}

.todo-item:first-child {
  border-top: 0;
}

.todo-overdue {
  background: color-mix(in srgb, var(--danger-tint) 55%, transparent);
}

.todo-check {
  flex: none;
  padding-top: 0.1rem;
}

.todo-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 2px solid var(--line-strong);
  border-radius: 0.4rem;
  background: var(--surface);
  color: var(--on-brand);
  cursor: pointer;
}

.todo-box:hover {
  border-color: var(--brand);
}

.todo-box.is-done {
  background: var(--ok);
  border-color: var(--ok);
}

.todo-box .icon {
  width: 1rem;
  height: 1rem;
}

.todo-body {
  flex: 1 1 auto;
  min-width: 0;
}

.todo-done .todo-title {
  text-decoration: line-through;
  color: var(--muted);
}

.card-section {
  border-top: 1px solid var(--line);
}

.card-section > summary {
  padding: 0.6rem 1.1rem;
  cursor: pointer;
}

.text-danger {
  color: var(--danger);
}

.row-unread td {
  font-weight: 600;
}

/* One-time secrets shown exactly once (portal passwords, invitation links). */
.secret-card {
  border-color: var(--warn-line);
  background: var(--warn-tint);
}

.secret {
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed var(--warn-line);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  user-select: all;
}

.break {
  overflow-wrap: anywhere;
}

/* --- Conversation page: people on the left, thread on the right ----------- */
.chat-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 24rem;
}

@media (min-width: 60rem) {
  .chat-page {
    grid-template-columns: 18rem minmax(0, 1fr);
  }

  .chat-people {
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
}

.chat-people {
  border-bottom: 1px solid var(--line);
}

.chat-people ul {
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  max-height: 24rem;
  overflow-y: auto;
}

.chat-person {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.chat-person:hover {
  background: var(--surface-2);
}

.chat-person.is-active {
  background: var(--brand-tint);
}

.chat-person-new .icon {
  color: var(--brand);
}

.chat-person-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.chat-person-text > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-pane .chat-scroll {
  flex: 1 1 auto;
  padding: 1rem;
}

.chat-pane-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
}

/* --- Floating chat widget (Messenger style) ------------------------------- */
.chatw {
  position: fixed;
  right: calc(1rem + env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.chatw-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: var(--shadow-2);
  cursor: pointer;
}

.chatw-launcher .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.chatw-launcher:hover {
  background: var(--brand-strong);
}

.chatw-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--canvas);
}

.chatw-panel {
  display: flex;
  flex-direction: column;
  width: min(22rem, calc(100vw - 2rem));
  height: min(32rem, calc(100dvh - 7rem));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}

.chatw-head {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.5rem 0.4rem 0.75rem;
  background: var(--nav-bg);
  color: var(--nav-ink-strong);
}

.chatw-head .btn-ghost {
  color: var(--nav-ink-strong);
}

.chatw-title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 650;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chatw-list {
  flex: 1 1 auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  overflow-y: auto;
}

.chatw-person {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.chatw-person:hover {
  background: var(--surface-2);
}

.chatw-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  list-style: none;
}

.chatw-thread {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.chatw-messages {
  flex: 1 1 auto;
  padding: 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chatw-messages .chat-msg {
  max-width: 88%;
}

.chatw-compose {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.chatw-compose textarea {
  flex: 1 1 auto;
  min-height: 2.5rem;
  max-height: 10rem;
  resize: none;
}

.chatw-note {
  margin: 0;
  padding: 0.4rem 0.75rem 0.6rem;
}

@media (max-width: 40rem) {
  .chatw.is-open {
    inset: 0;
    align-items: stretch;
    gap: 0;
  }

  .chatw.is-open .chatw-panel {
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .chatw.is-open .chatw-launcher {
    display: none;
  }
}

@media print {
  .chatw {
    display: none;
  }
}

.chat-people-wide {
  margin: 0;
  padding: 0.4rem;
  list-style: none;
}

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

.list-plain li {
  padding: 0.6rem 1.1rem;
  border-top: 1px solid var(--line);
}

.list-plain li:first-child {
  border-top: 0;
}
