@layer components {
  /* ── Buttons ─────────────────────────────────────────────────────────── */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: -0.005em;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.35s var(--ease-spring);
  }
  .btn .ico { width: 18px; height: 18px; margin-inline-start: -2px; }
  .btn:active:not(:disabled) { transform: scale(0.97); }
  .btn:disabled { opacity: 0.55; }
  .btn--primary { background: var(--ink); color: var(--bg); }
  .btn--accent { background: var(--accent); color: var(--on-accent); }
  .btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
  .btn--danger { background: var(--bad); color: #fff; }
  :root[data-theme="dark"] .btn--danger { color: #1a0605; }
  .btn--quiet { background: transparent; color: var(--ink-2); padding-inline: 10px; }
  .btn--sm { height: 32px; padding: 0 12px; font-size: var(--fs-xs); border-radius: 9px; }
  .btn--sm .ico { width: 16px; height: 16px; }
  .btn--block { width: 100%; }
  @media (hover: hover) {
    .btn:hover:not(:disabled) { background: var(--surface-3); }
    .btn--primary:hover:not(:disabled) { background: var(--accent-deep); color: #fff; }
    :root[data-theme="dark"] .btn--primary:hover:not(:disabled) { color: var(--bg); }
    .btn--accent:hover:not(:disabled) { background: var(--accent-deep); color: #fff; }
    :root[data-theme="dark"] .btn--accent:hover:not(:disabled) { color: var(--on-accent); }
    .btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-3); }
    .btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 85%, var(--ink)); }
    .btn--quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
  }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex: none;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-2);
    transition: background-color 0.2s, color 0.2s, transform 0.35s var(--ease-spring);
  }
  .icon-btn .ico { width: 20px; height: 20px; }
  .icon-btn--sm { width: 28px; height: 28px; border-radius: 8px; }
  .icon-btn--sm .ico { width: 16px; height: 16px; }
  .icon-btn:active { transform: scale(0.92); }
  @media (hover: hover) {
    .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  }

  /* Toolbar buttons in the top bar */
  .tool {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.35s var(--ease-spring);
  }
  .tool .ico { width: 18px; height: 18px; }
  .tool:active { transform: scale(0.97); }
  .tool.is-on,
  .tool[aria-pressed="true"],
  .tool[aria-expanded="true"] {
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent-deep);
  }
  .tool__dot {
    display: inline-grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--accent);
    color: var(--on-accent);
    font-size: 0.6875rem;
    font-weight: 700;
  }
  .tool__dot:empty { display: none; }
  @media (hover: hover) {
    .tool:hover { color: var(--ink); border-color: var(--ink-3); }
  }

  .kbd {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink-3);
    font: 600 0.6875rem/1 var(--font);
    letter-spacing: 0.02em;
  }

  /* ── Cards and page structure ────────────────────────────────────────── */
  .card {
    position: relative;
    padding: var(--pad);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }
  .card__title {
    font-size: var(--fs-lg);
    font-weight: 650;
    letter-spacing: -0.02em;
  }
  .card__aside {
    color: var(--ink-3);
    font-size: var(--fs-xs);
    font-weight: 600;
  }
  .card__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-deep);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
  }
  .card__link .ico { width: 16px; height: 16px; transition: transform 0.3s var(--ease-out); }
  .card__link:hover .ico { transform: translateX(3px); }

  .band {
    container: band / inline-size;
    padding: clamp(18px, 2.2vw, 32px) var(--edge) clamp(22px, 2.6vw, 40px);
    background: var(--band);
  }
  .body {
    padding: var(--gap) var(--edge) clamp(40px, 5vw, 72px);
  }
  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    color: var(--accent-deep);
    font-size: var(--fs-xs);
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .title {
    font-size: var(--fs-title);
    font-weight: 650;
    letter-spacing: -0.035em;
    line-height: 1.08;
  }
  .title .w { display: inline-block; }
  .lede {
    max-width: 62ch;
    margin-top: 8px;
    color: var(--ink-2);
    font-size: var(--fs-md);
  }
  .band__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--gap);
  }

  /* Figures: the big numbers in each page's band */
  /* Figures sit in one row when there's room and fold to 2 × 2 when the
     band is narrow, whatever the sidebar is doing. */
  /* No cards: the figures sit on the band itself, a hairline between each
     (Paul, 20 Oct 2026). A figure that does something shows a surface only
     while it's hovered. */
  .figs {
    --fig-rule: color-mix(in srgb, var(--ink) 12%, transparent);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0;
    margin-top: clamp(18px, 2vw, 28px);
  }
  .fig {
    display: grid;
    gap: 6px;
    align-content: start;
    padding: 4px clamp(16px, 2vw, 28px);
    border: 0;
    border-left: 1px solid var(--fig-rule);
    border-radius: 0;
    background: none;
  }
  .figs > .fig:first-child { padding-left: 0; border-left: 0; }
  @container band (width < 860px) {
    .figs {
      grid-auto-flow: row;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      row-gap: 18px;
    }
    .figs > .fig:nth-child(odd) { padding-left: 0; border-left: 0; }
    .figs > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  }
  @container band (width < 520px) {
    .fig { padding-right: 10px; }
    .fig__value { font-size: 1.5rem; }
    .fig__label { font-size: var(--fs-xs); }
  }
  /* Label on top, the number, then a note: the style the newer bands use. */
  .fig--top, .fig--ring { gap: 4px; }
  .fig__top { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; }
  .fig__top .ico { flex: none; color: var(--ink-3); }
  .fig--top .fig__value, .fig--ring .fig__value { margin: 4px 0 2px; }
  .fig__note { color: var(--ink-3); font-size: var(--fs-xs); }
  .fig--ring { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 16px; }
  .fig__text { display: grid; gap: 4px; min-width: 0; }
  .fig__ring { display: grid; }
  .fig__ring .ring__value { stroke: var(--ink); }
  .fig__pct { margin-left: 2px; font-size: 0.5em; font-weight: 600; letter-spacing: 0; }
  /* Title on the left, the figures beside it, when the band is wide enough. */
  @container band (width >= 1100px) {
    .band-split { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2.4fr); align-items: end; gap: var(--gap); }
    .band-split > .figs { margin-top: 0; }
    /* A ring needs room beside its words. */
    .band-split > .figs:has(> .fig--ring:last-child) { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.45fr); }
  }
  .fig__value {
    white-space: nowrap;
    font-size: var(--fs-fig);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.035em;
    line-height: 1;
  }
  .fig__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 500;
  }
  .delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 0.6875rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }
  .delta--up { background: var(--good-bg); color: var(--good); }
  .delta--down { background: var(--bad-bg); color: var(--bad); }

  .grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
    gap: var(--gap);
  }

  /* ── Form fields ─────────────────────────────────────────────────────── */
  .field {
    display: grid;
    gap: 6px;
    align-content: start;
  }
  .field__label {
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 600;
  }
  .field__hint {
    color: var(--ink-3);
    font-size: var(--fs-xs);
  }
  .field__error {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--bad);
    font-size: var(--fs-xs);
    font-weight: 600;
  }
  .field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  @media (width <= 520px) {
    .field-row { grid-template-columns: 1fr; }
  }
  .form-stack {
    display: grid;
    gap: 16px;
  }

  .input,
  .select,
  .textarea {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--field-line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    font-size: var(--fs-md);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  }
  .input::placeholder,
  .textarea::placeholder {
    color: var(--ink-3);
    opacity: 1;
  }
  .input:focus,
  .select:focus,
  .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
  }
  .input[aria-invalid="true"],
  .select[aria-invalid="true"],
  .textarea[aria-invalid="true"] {
    border-color: var(--bad);
    box-shadow: 0 0 0 3px var(--bad-bg);
  }
  .textarea {
    height: auto;
    min-height: 96px;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
  }
  .select {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6774' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    cursor: pointer;
  }
  :root[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa5b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  }
  .input--sm, .select--sm { height: 34px; font-size: var(--fs-sm); }
  .input:disabled,
  .select:disabled,
  .textarea:disabled {
    border-style: dashed;
    background-color: var(--surface-2);
    color: var(--ink-2);
    cursor: not-allowed;
  }

  .check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
  }
  .check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
  }

  /* Switch */
  .switch {
    position: relative;
    flex: none;
    width: 42px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--field-line);
    border-radius: var(--r-pill);
    background: var(--surface-3);
    transition: background-color 0.25s, border-color 0.25s;
  }
  .switch i {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
    transition: transform 0.35s var(--ease-spring);
  }
  .switch[aria-checked="true"] {
    background: var(--accent);
    border-color: var(--accent);
  }
  .switch[aria-checked="true"] i { transform: translateX(18px); }
  :root[data-theme="dark"] .switch[aria-checked="true"] i { background: var(--bg); }

  /* Segmented control */
  .seg {
    position: relative;
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-2);
    border: 1px solid var(--line);
  }
  .seg button {
    position: relative;
    z-index: 1;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: color 0.2s;
  }
  .seg button[aria-pressed="true"] { color: var(--ink); }
  .seg button:disabled { cursor: not-allowed; opacity: 0.6; }
  .seg__thumb {
    position: absolute;
    top: 3px;
    left: 0;
    height: 32px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 0 rgb(33 51 67 / 0.05), 0 2px 8px -2px rgb(33 51 67 / 0.18);
    pointer-events: none;
  }
  :root[data-theme="dark"] .seg__thumb { background: var(--surface-3); }

  /* Chips */
  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.35s var(--ease-spring);
  }
  .chip b {
    color: var(--ink-3);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
  }
  .chip[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--ink);
    color: var(--bg);
  }
  .chip[aria-pressed="true"] b { color: inherit; opacity: 0.7; }
  .chip:active { transform: scale(0.96); }

  /* Tags and stage pills */
  .tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }
  .tag .ico { width: 14px; height: 14px; }
  a.tag:hover { background: var(--surface-3); color: var(--ink); }
  .band .tag { background: color-mix(in srgb, var(--surface) 75%, transparent); }

  .stage {
    --tone: var(--ink-3);
    --tone-soft: var(--surface-2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 26px;
    padding: 0 10px 0 8px;
    border-radius: var(--r-pill);
    background: var(--tone-soft);
    color: var(--ink);
    font-size: var(--fs-xs);
    font-weight: 650;
    white-space: nowrap;
  }
  .stage i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tone);
  }
  .stage--enquiry { --tone: var(--c2); --tone-soft: var(--c2-soft); }
  .stage--discovery { --tone: var(--c4); --tone-soft: var(--c4-soft); }
  .stage--proposal { --tone: var(--c1); --tone-soft: var(--c1-soft); }
  .stage--won { --tone: var(--c3); --tone-soft: var(--c3-soft); }
  .stage--lost { --tone: var(--ink-3); --tone-soft: var(--surface-3); }

  .meta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ink-3);
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
  }
  .meta .ico { width: 14px; height: 14px; }
  .meta--late { color: var(--bad); }
  .meta--soon { color: var(--warn); }

  /* ── Avatars ─────────────────────────────────────────────────────────── */
  .av {
    --size: 36px;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--ink);
    font-size: calc(var(--size) * 0.36);
    font-weight: 650;
    letter-spacing: 0.01em;
    object-fit: cover;
    user-select: none;
  }
  .av--xs { --size: 22px; font-size: 0.5625rem; }
  .av--sm { --size: 28px; }
  .av--md { --size: 36px; }
  .av--lg { --size: 56px; }
  .av--xl { --size: 96px; }
  .av--t0 { background: var(--c1-soft); }
  .av--t1 { background: var(--c2-soft); }
  .av--t2 { background: var(--c3-soft); }
  .av--t3 { background: var(--c4-soft); }

  .who {
    position: relative;
    display: inline-block;
    flex: none;
    line-height: 0;
  }
  .who__dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--side-bg);
    border-radius: 50%;
    background: var(--accent);
  }
  .who__dot--off {
    background: var(--side-bg);
    box-shadow: inset 0 0 0 2px var(--ink-3);
  }

  .stack {
    display: inline-flex;
    padding-left: 6px;
  }
  .stack > * {
    margin-left: -6px;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .band .stack > * { box-shadow: 0 0 0 2px var(--band); }

  .logo-tile {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 700;
  }
  .logo-tile--lg { width: 64px; height: 64px; border-radius: 16px; font-size: var(--fs-lg); }

  /* ── Menus and popovers ──────────────────────────────────────────────── */
  .menu,
  .pop {
    position: fixed;
    z-index: var(--z-pop);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
  }
  .menu {
    min-width: 210px;
    padding: 6px;
  }
  .menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-align: left;
  }
  .menu__item .ico { width: 18px; height: 18px; color: var(--ink-3); }
  .menu__item:hover,
  .menu__item:focus-visible {
    outline: none;
    background: var(--surface-2);
    color: var(--ink);
  }
  .menu__item[aria-checked="true"] { color: var(--ink); font-weight: 650; }
  .menu__item[aria-checked="true"]::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--accent);
  }
  .menu__item.is-danger,
  .menu__item.is-danger .ico { color: var(--bad); }
  .menu__sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--line);
  }

  .pop {
    width: min(320px, calc(100vw - 16px));
    max-height: calc(100dvh - 16px);
    padding: 14px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .pop__title {
    margin-bottom: 8px;
    color: var(--ink-3);
    font-size: var(--fs-xs);
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }
  .pop__foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .fset + .fset { margin-top: 14px; }
  .fset__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 10px;
  }

  /* ── Dialogs: modal and drawer ───────────────────────────────────────── */
  .modal,
  .drawer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 24px 16px;
    border: 0;
    background: transparent;
    color: var(--ink);
    overflow: hidden;
  }
  .modal::backdrop,
  .drawer::backdrop { background: transparent; }
  .modal::before,
  .drawer::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--scrim-color);
    opacity: var(--scrim, 1);
  }
  .modal[open] { display: grid; place-items: center; }
  .drawer[open] { display: block; padding: 0; }

  .modal__form,
  .drawer__form {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--surface);
    box-shadow: var(--shadow-lift);
  }
  .modal__form {
    width: min(520px, 100%);
    max-height: calc(100dvh - 48px);
    border: 1px solid var(--line);
    border-radius: 18px;
  }
  .modal--wide .modal__form { width: min(720px, 100%); }
  .drawer__form {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 100%);
    border-left: 1px solid var(--line);
    border-radius: 18px 0 0 18px;
  }
  .modal__head,
  .drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 6px 22px;
  }
  .modal__title,
  .drawer__title {
    font-size: var(--fs-xl);
    font-weight: 650;
    letter-spacing: -0.025em;
  }
  .modal__body,
  .drawer__body {
    padding: 10px 22px 20px;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .modal__text { color: var(--ink-2); }
  .modal__foot,
  .drawer__foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 20px;
    border-top: 1px solid var(--line);
  }
  @media (width <= 520px) {
    .modal { padding: 0; }
    .modal[open] { place-items: end stretch; }
    .modal__form,
    .modal--wide .modal__form {
      width: 100%;
      max-height: calc(100dvh - 24px);
      border-radius: 18px 18px 0 0;
      padding-bottom: env(safe-area-inset-bottom);
    }
    .modal__foot > .btn { flex: 1; }
    .drawer__form { border-radius: 0; }
  }

  /* ── Toast ───────────────────────────────────────────────────────────── */
  .toast {
    position: fixed;
    inset: auto 0 max(20px, env(safe-area-inset-bottom)) 0;
    z-index: var(--z-toast);
    width: fit-content;
    max-width: calc(100% - 32px);
    margin: 0 auto;
    padding: 10px 10px 10px 16px;
    border: 0;
    border-radius: 12px;
    background: var(--ink);
    color: var(--bg);
    box-shadow: var(--shadow-lift);
    font-size: var(--fs-sm);
    font-weight: 600;
    overflow: visible;
    display: none;
  }
  .toast:popover-open,
  .toast.is-open {
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .toast:not(.has-action) { padding-right: 16px; }
  .toast__icon { width: 18px; height: 18px; color: var(--accent-soft); }
  :root[data-theme="dark"] .toast__icon { color: var(--accent-deep); }
  .toast__action {
    height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: rgb(255 255 255 / 0.14);
    color: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
  }
  .toast__action:hover { background: rgb(255 255 255 / 0.24); }
  :root[data-theme="dark"] .toast__action { background: rgb(33 51 67 / 0.1); }
  :root[data-theme="dark"] .toast__action:hover { background: rgb(33 51 67 / 0.18); }

  /* ── Feedback ────────────────────────────────────────────────────────── */
  .empty {
    display: grid;
    justify-items: center;
    gap: 6px;
    padding: clamp(28px, 4vw, 48px) 16px;
    text-align: center;
  }
  .empty > .ico {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    padding: 12px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--accent-deep);
  }
  .empty__title {
    font-size: var(--fs-md);
    font-weight: 650;
  }
  .empty__text {
    max-width: 44ch;
    color: var(--ink-3);
    font-size: var(--fs-sm);
  }
  .empty .btn { margin-top: 10px; }

  .bar {
    position: relative;
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    overflow: hidden;
  }
  .bar > i {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--accent);
    transform-origin: left center;
  }
  .bar--warn > i { background: var(--c2); }
  .bar--bad > i { background: var(--bad); }

  .ring {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex: none;
  }
  .ring svg { transform: rotate(-90deg); }
  .ring__track { stroke: var(--surface-3); }
  .ring__value { stroke: var(--accent); stroke-linecap: round; }
  .ring__label {
    position: absolute;
    font-size: var(--fs-xs);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  /* Task priority: a small diamond, tinted, beside the word. */
  .prio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
    font-size: var(--fs-xs);
    font-weight: 650;
    white-space: nowrap;
  }
  .prio i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: var(--ink-3);
    transform: rotate(45deg);
  }
  .prio--high i { background: var(--bad); }
  .prio--medium i { background: var(--c2); }
  .prio--low i { background: var(--c1); }

  /* Task drawer (opened from Tasks now, from the dashboard and team later). */
  .tkd { display: grid; gap: 16px; }
  .tkd__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    transition: background-color 0.3s, color 0.3s;
  }
  .tkd__status.is-done { background: var(--good-bg); color: var(--good); }
  .tkd__state {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-sm);
    font-weight: 650;
  }
  .tkd__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
  }
  .tkd__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    color: var(--ink-3);
    font-size: var(--fs-sm);
  }
  .tkd__meta .ico { display: inline-block; margin-right: 4px; vertical-align: -2px; }
  .tkd__meta a { color: var(--ink-2); }
  .tkd__saved {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-3);
    font-size: var(--fs-xs);
    transition: color 0.2s;
  }
  .tkd__saved.is-on { color: var(--good); font-weight: 600; }
  .drawer__foot .btn--quiet:first-child { margin-right: auto; color: var(--bad); }

  /* Round check with a little burst on completion */
  .tk-check {
    position: relative;
    display: grid;
    place-items: center;
    flex: none;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid var(--field-line);
    border-radius: 50%;
    background: var(--surface);
    color: transparent;
    transition: border-color 0.2s, background-color 0.25s, color 0.2s;
  }
  @media (hover: hover) {
    .tk-check:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 55%, transparent); }
  }
  .tk-check[aria-checked="true"] {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
  }
  .tk-check.is-burst::after {
    content: "";
    position: absolute;
    inset: -6px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: tk-burst 0.6s ease-out forwards;
    pointer-events: none;
  }
  @keyframes tk-burst {
    from { opacity: 1; transform: scale(0.6); }
    to { opacity: 0; transform: scale(1.7); }
  }

  /* Mini task list (dashboard, member profile, project) */
  .mt-list {
    display: grid;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .mt-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: 10px;
    transition: background-color 0.6s;
  }
  @media (hover: hover) {
    .mt-row:hover { background: var(--surface-2); transition-duration: 0.15s; }
  }
  .mt-row.is-new { background: var(--accent-soft); transition-duration: 0s; }
  .mt-title {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: var(--fs-sm);
    text-align: left;
    cursor: pointer;
  }
  .mt-title > span:first-child {
    background: linear-gradient(currentColor, currentColor) 0 60% / 0% 1.5px no-repeat;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    transition: background-size 0.4s var(--ease-out);
  }
  .mt-title small {
    display: block;
    overflow: hidden;
    color: var(--ink-3);
    font-size: var(--fs-xs);
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mt-row.is-done .mt-title { color: var(--ink-3); }
  .mt-row.is-done .mt-title > span:first-child { background-size: 100% 1.5px; }
  .mt-row .meta { flex: none; }

  /* Month bars (revenue, deals won): one tab stop, arrows read each month. */
  .mb {
    --n: 6;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 180px auto;
    gap: 8px 10px;
    border-radius: 10px;
    outline-offset: 6px;
  }
  .mb:focus-visible { outline: 2px solid var(--accent); }
  .mb__axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--ink-3);
    font-size: 0.6875rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-align: right;
  }
  .mb__area {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    gap: clamp(4px, 1.2vw, 14px);
    align-items: end;
    border-bottom: 1px solid var(--line-strong);
    background:
      linear-gradient(var(--line) 0 0) 0 0 / 100% 1px no-repeat,
      linear-gradient(var(--line) 0 0) 0 50% / 100% 1px no-repeat;
  }
  .mb__col {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 100%;
  }
  .mb__bar {
    position: relative;
    display: block;
    width: min(34px, 72%);
    height: 0;
    border-radius: 7px 7px 2px 2px;
    background: color-mix(in srgb, var(--accent) 32%, var(--surface-2));
    transition: background-color 0.2s;
  }
  .mb__col.is-current .mb__bar { background: var(--accent); }
  .mb__col:hover .mb__bar,
  .mb__col.is-focus .mb__bar { background: var(--accent-deep); }
  .mb__tip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 3;
    display: grid;
    justify-items: center;
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--ink);
    color: var(--bg);
    font-size: var(--fs-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity 0.15s, transform 0.2s var(--ease-out);
  }
  .mb__tip small { font-weight: 500; opacity: 0.75; }
  .mb__col:hover .mb__tip,
  .mb__col.is-focus .mb__tip { opacity: 1; transform: translate(-50%, 0); }
  .mb__target {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
    border-top: 1.5px dashed var(--c2);
    pointer-events: none;
  }
  .mb__target span {
    position: absolute;
    top: -9px;
    right: 0;
    padding: 0 5px;
    border-radius: 4px;
    background: var(--surface);
    color: var(--warn);
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 16px;
  }
  .mb__labels {
    grid-column: 2;
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    gap: clamp(4px, 1.2vw, 14px);
    color: var(--ink-3);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-align: center;
  }
  @container (width < 520px) {
    .mb__labels { font-size: 0.625rem; }
  }

  /* Activity kinds: one round, tinted icon per kind of update. */
  .kind-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--ink-2);
  }
  /* Glyph tints are pulled towards ink so each icon clears 3:1 on its tint. */
  .kind-icon--call { background: var(--c1-soft); color: color-mix(in srgb, var(--c1) 72%, var(--ink)); }
  .kind-icon--email { background: var(--surface-2); color: var(--ink-2); }
  .kind-icon--meeting { background: var(--c4-soft); color: color-mix(in srgb, var(--c4) 72%, var(--ink)); }
  .kind-icon--won { background: var(--c3-soft); color: var(--good); }
  .kind-icon--stage { background: var(--c1-soft); color: color-mix(in srgb, var(--c1) 72%, var(--ink)); }
  .kind-icon--created { background: var(--c2-soft); color: var(--warn); }
  .kind-icon--task { background: var(--accent-soft); color: var(--accent-deep); }

  .divider {
    height: 1px;
    margin: 14px 0;
    border: 0;
    background: var(--line);
  }

  .list-plain {
    display: grid;
    gap: 2px;
  }

  .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
  }
  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  /* "You" beside your own name, wherever people are listed. */
  .mcard__you {
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-size: 0.625rem;
    font-weight: 700;
    vertical-align: 2px;
  }

  /* ── Member level badge ─────────────────────────────────────────────── */
  .lvl {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
    padding: 1px 7px 1px 6px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    vertical-align: 2px;
    white-space: nowrap;
  }
  .lvl .ico { width: 12px; height: 12px; }
  .lvl--admin { background: var(--accent-soft); color: var(--accent-deep); }
  .lvl--manager { background: var(--c1-soft); color: var(--ink); }

  /* ── Level preview bar (an Admin seeing the app as someone else) ──────── */
  .preview-bar {
    position: sticky;
    top: 0;
    z-index: calc(var(--z-top) + 1);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 14px;
    padding: 8px var(--edge);
    background: var(--ink);
    color: var(--bg);
    font-size: var(--fs-sm);
    font-weight: 600;
    text-align: center;
  }
  .preview-bar .ico { color: var(--accent); }
  .preview-bar__stop { background: var(--accent); color: var(--on-accent); }
  @media (hover: hover) {
    .preview-bar__stop:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
  }

  /* ── Demo marker, no-deal stage, Board / List switch ────────────────── */
  .demo-tag {
    display: inline-flex;
    flex: none;
    align-items: center;
    height: 18px;
    margin-left: 6px;
    padding: 0 6px;
    border: 1px dashed var(--line-strong);
    border-radius: 5px;
    color: var(--ink-3);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: 2px;
    white-space: nowrap;
  }
  .stage--none { --tone: var(--line-strong); --tone-soft: var(--surface-2); color: var(--ink-2); }

  .vswitch {
    display: inline-flex;
    padding: 3px;
    border-radius: 11px;
    background: var(--surface-2);
  }
  .vswitch a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: var(--fs-xs);
    font-weight: 650;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
  }
  .vswitch a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
  .vswitch a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
  @media (hover: hover) {
    .vswitch a:not([aria-current]):hover { color: var(--ink); }
  }

  /* "+3" at the end of an avatar stack. */
  .stack__more {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 0.625rem;
    font-weight: 700;
  }

  /* ── Line chart (ui/charts.js lineChart) ─────────────────────────────── */
  .lc { position: relative; outline: none; touch-action: pan-y; }
  .lc:focus-visible { border-radius: 10px; box-shadow: 0 0 0 3px var(--accent-ring); }
  .lc__svg { display: block; overflow: visible; }
  .lc__grid line { stroke: var(--line); stroke-width: 1; }
  .lc__grid line:first-child { stroke: var(--line-strong); }
  .lc__grid text,
  .lc__x text {
    fill: var(--ink-3);
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .lc__grid text { text-anchor: end; }
  .lc__x text { text-anchor: middle; }
  .lc__x text.is-now,
  .lc__x text.is-focus { fill: var(--ink); font-weight: 750; }
  .lc__stop-top { stop-color: var(--accent); stop-opacity: 0.26; }
  .lc__stop-end { stop-color: var(--accent); stop-opacity: 0; }
  .lc__line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .lc__pts circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; opacity: 0; transition: opacity 0.3s; }
  .lc.is-drawn .lc__pts circle { opacity: 1; }
  .lc__target { stroke: var(--c2); stroke-width: 1.5; stroke-dasharray: 5 5; }
  .lc__cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0; transition: opacity 0.15s; }
  .lc__dot { fill: var(--surface); stroke: var(--accent); stroke-width: 3; opacity: 0; transition: opacity 0.15s; }
  .lc.is-hover .lc__cross,
  .lc.is-hover .lc__dot { opacity: 1; }
  /* The hot point: this month, with a slow pulse. */
  .lc__now { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
  .lc__halo {
    fill: var(--accent);
    opacity: 0.22;
    transform-box: fill-box;
    transform-origin: center;
    animation: lc-pulse 2.4s var(--ease-out) infinite;
  }
  @keyframes lc-pulse {
    0% { opacity: 0.32; transform: scale(0.45); }
    70%, 100% { opacity: 0; transform: scale(1.35); }
  }
  :root[data-motion="reduced"] .lc__halo { animation: none; opacity: 0.18; }
  .lc__tip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    display: grid;
    gap: 1px;
    min-width: 120px;
    padding: 8px 11px;
    border-radius: 10px;
    background: var(--ink);
    box-shadow: var(--shadow-pop);
    color: var(--bg);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
  }
  .lc.is-hover .lc__tip { opacity: 1; }
  .lc__tip-m { color: color-mix(in srgb, var(--bg) 72%, transparent); font-size: 0.6875rem; font-weight: 650; }
  .lc__tip-v { font-size: var(--fs-md); font-weight: 750; font-variant-numeric: tabular-nums; }
  .lc__tip-d { color: color-mix(in srgb, var(--bg) 80%, transparent); font-size: 0.6875rem; font-weight: 600; }
}
