/* =============================================================================
   Component layer (§2.4). All reusable UI lives here, `hh-` prefixed. Adding a
   theme is a variable block (20-theme.css), never new components.

   Swiss typographic: flush-left type on one grid, a heavy rule to open a
   section, hairlines between rows, square corners, no resting shadows. Ink is
   the primary action; red marks only the place you are and what needs you.
   ========================================================================== */

body {
  font-family: var(--hh-font-sans);
  font-size: var(--hh-fs-2);
  line-height: 1.5;
  background: var(--hh-bg);
  color: var(--hh-ink);
  font-feature-settings: "tnum" 0;
}
/* every figure that can be compared is set in tabular lining numerals */
.hh-num, .hh-table td, .hh-amount { font-variant-numeric: tabular-nums lining-nums; }

/* ---------- App shell layout ---------- */
.hh-app { min-height: 100vh; display: flex; flex-direction: column; }
.hh-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--hh-measure);
  margin-inline: auto;
  padding: var(--hh-space-6) var(--hh-space-6) var(--hh-space-12);
}
.hh-footer { flex: none; padding-top: var(--hh-space-4); padding-bottom: var(--hh-space-5); }
.hh-footer > div { border-top: var(--hh-rule) solid var(--hh-border); padding-top: var(--hh-space-3); }

.hh-page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: var(--hh-space-3) var(--hh-space-5);
  margin-bottom: var(--hh-space-5);
}
.hh-page-title {
  font-size: var(--hh-fs-4); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1;
}
.hh-page-sub { color: var(--hh-ink-soft); margin-top: var(--hh-space-1); max-width: 68ch; }
.hh-section-title {
  font-size: var(--hh-fs-3); font-weight: 700; letter-spacing: -0.01em; line-height: 1.25;
}
.hh-link { text-decoration: underline; text-decoration-color: var(--hh-border-strong); }
.hh-link:hover { text-decoration-color: currentColor; }

/* A section: opened by the heavy rule, its title flush left above the content. */
.hh-sec {
  border-top: var(--hh-rule-heavy) solid var(--hh-rule-color);
  padding-top: var(--hh-space-3);
  margin-top: var(--hh-space-8);
}
.hh-sec:first-child { margin-top: 0; }
.hh-sec__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--hh-space-4);
  margin-bottom: var(--hh-space-4);
}
.hh-sec__title { font-size: var(--hh-fs-2); font-weight: 700; }
.hh-sec__aside { font-size: var(--hh-fs-1); color: var(--hh-muted); }
/* Two-column section: the label hangs in a narrow left column (desktop). */
.hh-sec--split {
  display: grid; grid-template-columns: minmax(9rem, 3fr) 9fr; gap: var(--hh-space-5);
}
.hh-sec--split > .hh-sec__head { margin: 0; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: var(--hh-space-1); }

/* ---------- Navbar: wordmark, destinations, you ---------- */
.hh-nav {
  position: sticky; top: 0; z-index: var(--hh-z-sticky);
  display: flex; align-items: stretch; gap: var(--hh-space-6);
  height: var(--hh-nav-h);
  /* the wordmark sits on the content's left edge, not the window's */
  padding: 0 max(var(--hh-space-6), calc((100% - var(--hh-measure)) / 2 + var(--hh-space-6)));
  background: var(--hh-surface);
  border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-brand {
  display: inline-flex; align-items: center; gap: var(--hh-space-2);
  font-weight: 700; font-size: var(--hh-fs-3); letter-spacing: -0.03em;
}
.hh-brand__mark { width: 12px; height: 12px; background: var(--hh-accent); flex: none; }
.hh-nav__links { display: flex; align-items: stretch; gap: var(--hh-space-5); }
.hh-nav__spacer { flex: 1 1 auto; }
.hh-nav__tools { display: flex; align-items: center; gap: var(--hh-space-1); }

.hh-navlink {
  display: inline-flex; align-items: center; gap: 0.4em;
  color: var(--hh-ink-soft); font-weight: 500; font-size: var(--hh-fs-2);
  box-shadow: inset 0 -2px 0 transparent;
  transition: color var(--hh-dur-fast) var(--hh-ease-out),
              box-shadow var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-navlink:hover { color: var(--hh-ink); }
.hh-navlink--active { color: var(--hh-ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--hh-accent); }
/* the count is work waiting for you, so it is the signal colour */
.hh-navlink__count {
  font-size: var(--hh-fs-1); font-weight: 700; color: var(--hh-accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- Mode action bar: what you can do here ---------- */
.hh-actionbar {
  position: sticky; top: var(--hh-nav-h); z-index: calc(var(--hh-z-sticky) - 1);
  background: var(--hh-surface); border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-actionbar__inner {
  width: 100%; max-width: var(--hh-measure); margin-inline: auto;
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--hh-space-2) var(--hh-space-5);
  min-height: 48px; padding: var(--hh-space-2) var(--hh-space-6);
}
.hh-modeaction {
  display: inline-flex; align-items: center; height: 32px;
  font-weight: 500; color: var(--hh-ink-soft);
  box-shadow: inset 0 -2px 0 transparent;
  transition: color var(--hh-dur-fast) var(--hh-ease-out), box-shadow var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-modeaction:hover { color: var(--hh-ink); }
.hh-modeaction.is-active { color: var(--hh-ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--hh-accent); }

/* ---------- Dropdowns ---------- */
.hh-dropdown { position: relative; display: inline-flex; }
.hh-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 224px;
  background: var(--hh-surface); border: var(--hh-rule) solid var(--hh-ink);
  box-shadow: var(--hh-shadow-lg);
  padding: var(--hh-space-1) 0; z-index: var(--hh-z-dropdown);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--hh-dur-fast) var(--hh-ease-out),
              transform var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-menu--left { right: auto; left: 0; }
.hh-dropdown[data-open="true"] .hh-menu { opacity: 1; transform: none; pointer-events: auto; }
/* In-table menu: the table wrap clips overflow, so the menu is positioned fixed (top/left
   set by app-core.js from the trigger's viewport rect) to escape the clip. */
.hh-dropdown--fixed .hh-menu { position: fixed; top: auto; right: auto; }
.hh-menu__label {
  font-size: var(--hh-fs-1); font-weight: 600; color: var(--hh-muted);
  padding: var(--hh-space-2) var(--hh-space-4) var(--hh-space-1);
}
.hh-menu__item {
  display: flex; align-items: center; gap: var(--hh-space-3);
  padding: var(--hh-space-2) var(--hh-space-4);
  color: var(--hh-ink); font-size: var(--hh-fs-2); width: 100%; text-align: left;
}
.hh-menu__item:hover { background: var(--hh-surface-2); }
.hh-menu__item--danger, .hh-menu__item--danger:hover { color: var(--hh-danger); }
.hh-menu__sep { display: block; height: 1px; background: var(--hh-border); margin: var(--hh-space-1) 0; }
.hh-menu__icon { width: 1rem; display: inline-flex; justify-content: center; color: var(--hh-ink-soft); }
.hh-menu__item--danger .hh-menu__icon { color: inherit; }
.hh-menu__check {
  display: flex; align-items: center; gap: var(--hh-space-3);
  padding: var(--hh-space-2) var(--hh-space-4);
  color: var(--hh-ink); cursor: pointer; user-select: none;
}
.hh-menu__check:hover { background: var(--hh-surface-2); }
.hh-menu__check input { margin: 0; }

/* Avatar: uploaded image or initial, square like everything else. */
.hh-avatar {
  width: 1.75rem; height: 1.75rem; flex: none; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--hh-ink); color: var(--hh-surface);
  font-weight: 700; font-size: var(--hh-fs-1); line-height: 1;
}
.hh-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hh-avatar--lg { width: 2.25rem; height: 2.25rem; font-size: var(--hh-fs-2); }

.hh-usermenu__trigger {
  display: inline-flex; align-items: center; gap: var(--hh-space-2);
  padding: var(--hh-space-1) var(--hh-space-2); color: var(--hh-ink);
  font: inherit; cursor: pointer;
  transition: background var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-usermenu__trigger:hover,
.hh-dropdown[data-open="true"] .hh-usermenu__trigger { background: var(--hh-surface-2); }
.hh-usermenu__name { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

/* ---------- Buttons ---------- */
.hh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--hh-space-2);
  height: 36px; padding: 0 var(--hh-space-4);
  font-weight: 600; font-size: var(--hh-fs-2); line-height: 1; white-space: nowrap;
  border: var(--hh-rule) solid transparent; color: var(--hh-ink); background: transparent;
  transition: background var(--hh-dur-fast) var(--hh-ease-out),
              border-color var(--hh-dur-fast) var(--hh-ease-out),
              color var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-btn--primary { background: var(--hh-primary); border-color: var(--hh-primary); color: var(--hh-primary-ink); }
.hh-btn--primary:hover { background: var(--hh-primary-hover); border-color: var(--hh-primary-hover); }
.hh-btn--ghost { border-color: var(--hh-border-strong); }
.hh-btn--ghost:hover { border-color: var(--hh-ink); }
/* subtle = a text button: no box, underline on hover */
.hh-btn--subtle { padding: 0 var(--hh-space-2); font-weight: 500; }
.hh-btn--subtle:hover { text-decoration: underline; text-underline-offset: 0.2em; }
.hh-btn--danger { background: var(--hh-danger); border-color: var(--hh-danger); color: var(--hh-danger-ink); }
.hh-btn--danger:hover { filter: brightness(0.94); }
.hh-btn--danger-text { color: var(--hh-danger); }
.hh-btn--sm { height: 30px; padding: 0 var(--hh-space-3); gap: 0.4rem; }
.hh-btn--icon { width: 36px; padding: 0; color: var(--hh-ink-soft); }
.hh-btn--icon:hover { background: var(--hh-surface-2); color: var(--hh-ink); text-decoration: none; }
.hh-btn--icon.hh-btn--sm { width: 30px; }
.hh-btn--active { box-shadow: inset 0 -2px 0 var(--hh-accent); color: var(--hh-ink); }
.hh-btn--block { width: 100%; }
.hh-btn:disabled { opacity: 0.45; pointer-events: none; }
.hh-icon { width: 1.15rem; height: 1.15rem; flex-shrink: 0; display: block; }

/* ---------- Tooltip ---------- */
[data-hh-tip] { position: relative; }
[data-hh-tip]::after {
  content: attr(data-hh-tip);
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--hh-ink); color: var(--hh-surface);
  padding: 0.3rem 0.5rem; font-size: var(--hh-fs-1); font-weight: 600; line-height: 1.2;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--hh-dur-fast) var(--hh-ease-out);
  z-index: var(--hh-z-tooltip);
}
[data-hh-tip]:hover::after, [data-hh-tip]:focus-visible::after { opacity: 1; }

/* in-page toolbar row (style guide demos) */
.hh-addon-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--hh-space-2); margin-bottom: var(--hh-space-4); }
.hh-addon-toolbar__sep { width: 1px; align-self: stretch; min-height: 1.4rem; background: var(--hh-border); margin: 0 var(--hh-space-1); }

/* loading: inline spinner revealed only while an HTMX request is in flight */
.hh-spin {
  width: 0.95em; height: 0.95em; flex-shrink: 0;
  border: 2px solid color-mix(in oklab, currentColor 30%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  display: inline-block; animation: hh-spin 0.6s linear infinite;
}
@keyframes hh-spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.htmx-request .hh-btn__label { opacity: 0.6; }
#ops-panel.htmx-request, #manager-table.htmx-request { opacity: 0.55; transition: opacity var(--hh-dur) var(--hh-ease-out); }

/* ---------- Forms ---------- */
.hh-field { display: flex; flex-direction: column; gap: var(--hh-space-1); }
.hh-label { font-weight: 600; font-size: var(--hh-fs-1); color: var(--hh-ink-soft); }
.hh-input, .hh-textarea, .hh-select,
.hh-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.hh-field textarea,
.hh-field select {
  width: 100%; min-height: 36px; padding: 0.4rem 0.6rem; font-size: var(--hh-fs-2);
  background: var(--hh-surface); color: var(--hh-ink);
  border: var(--hh-rule) solid var(--hh-border-strong); border-radius: 0;
  transition: border-color var(--hh-dur-fast) var(--hh-ease-out),
              box-shadow var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-input::placeholder, .hh-textarea::placeholder { color: var(--hh-muted); }
.hh-input:focus, .hh-textarea:focus, .hh-select:focus,
.hh-field input:focus, .hh-field textarea:focus, .hh-field select:focus {
  outline: none; border-color: var(--hh-ink); box-shadow: inset 0 0 0 1px var(--hh-ink);
}
.hh-field textarea { resize: vertical; min-height: 5rem; }
.hh-help { font-size: var(--hh-fs-1); color: var(--hh-ink-soft); }
.hh-error { font-size: var(--hh-fs-1); color: var(--hh-danger); font-weight: 600; }
.hh-field--error input:not([type="checkbox"]):not([type="radio"]),
.hh-field--error textarea,
.hh-field--error select { border-color: var(--hh-danger); }
.hh-field--error input:focus, .hh-field--error textarea:focus, .hh-field--error select:focus {
  border-color: var(--hh-danger); box-shadow: inset 0 0 0 1px var(--hh-danger);
}
.hh-field input:disabled, .hh-field textarea:disabled, .hh-field select:disabled,
.hh-input:disabled, .hh-textarea:disabled, .hh-select:disabled {
  background: var(--hh-surface-2); color: var(--hh-muted); cursor: not-allowed;
}
.hh-check { display: inline-flex; align-items: flex-start; gap: var(--hh-space-2); }
.hh-check input { margin-top: 3px; accent-color: var(--hh-ink); }

/* ---------- Panels: a ruled block, not a card ---------- */
.hh-panel { border-top: var(--hh-rule-heavy) solid var(--hh-rule-color); }
.hh-panel__body { padding: var(--hh-space-5) 0; }
.hh-panel__head {
  padding: var(--hh-space-3) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--hh-space-3);
}

/* ---------- Badges: small set text, never a coloured pill ---------- */
.hh-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 0 0.4rem; min-height: 1.35rem; font-size: var(--hh-fs-1); font-weight: 500; white-space: nowrap;
  background: var(--hh-surface-3); color: var(--hh-ink);
}
.hh-badge--accent { background: var(--hh-surface-3); color: var(--hh-ink); }
.hh-badge--success { background: transparent; color: var(--hh-ink-soft); padding: 0; }
.hh-badge--danger { background: transparent; color: var(--hh-danger); font-weight: 700; padding: 0; }
.hh-badge--dot::before { content: ""; width: 6px; height: 6px; background: currentColor; }

/* ---------- Notices: a rule and a sentence ---------- */
.hh-alert {
  display: flex; gap: var(--hh-space-3); align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap;
  padding: var(--hh-space-3) 0; margin-bottom: var(--hh-space-3);
  border-top: var(--hh-rule-heavy) solid var(--hh-border-strong);
  color: var(--hh-ink);
}
/* notices stay in ink: the words carry the state; red is kept for what needs you */
.hh-alert--success, .hh-alert--error, .hh-alert--warning { border-top-color: var(--hh-border-strong); }
.hh-alerts { margin-top: var(--hh-space-8); }
.hh-alerts:not(:has(.hh-alert)) { display: none; }

/* ---------- Toasts ---------- */
.hh-toasts {
  position: fixed; right: var(--hh-space-5); bottom: var(--hh-space-5);
  display: flex; flex-direction: column; gap: var(--hh-space-2);
  z-index: var(--hh-z-toast); max-width: min(92vw, 380px);
}
.hh-toast {
  background: var(--hh-ink); color: var(--hh-surface);
  box-shadow: var(--hh-shadow-lg);
  padding: var(--hh-space-3) var(--hh-space-4); font-weight: 500;
  animation: hh-toast-in var(--hh-dur) var(--hh-ease-out) both;
}
.hh-toast--error { background: var(--hh-danger); color: var(--hh-danger-ink); }
@keyframes hh-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Modal ---------- */
.hh-modal-backdrop {
  position: fixed; inset: 0; background: var(--hh-overlay);
  z-index: var(--hh-z-modal-backdrop); display: none;
  align-items: flex-start; justify-content: center; padding: 8vh var(--hh-space-4);
  opacity: 0; transition: opacity var(--hh-dur) var(--hh-ease-out);
  overflow-y: auto;
}
.hh-modal-backdrop[data-open="true"] { display: flex; opacity: 1; }
.hh-modal {
  width: 100%; max-width: 540px;
  background: var(--hh-surface);
  border-top: 4px solid var(--hh-ink);
  box-shadow: var(--hh-shadow-lg);
  z-index: var(--hh-z-modal);
  transform: translateY(10px);
  transition: transform var(--hh-dur) var(--hh-ease-out);
}
.hh-modal-backdrop[data-open="true"] .hh-modal { transform: none; }
.hh-modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--hh-space-3);
  padding: var(--hh-space-4) var(--hh-space-5) var(--hh-space-2);
}
.hh-modal__title { font-size: var(--hh-fs-3); font-weight: 700; letter-spacing: -0.01em; }
.hh-modal__body { padding: var(--hh-space-3) var(--hh-space-5) var(--hh-space-5); }
.hh-modal__foot {
  display: flex; justify-content: flex-end; gap: var(--hh-space-2);
  padding: var(--hh-space-3) var(--hh-space-5); border-top: var(--hh-rule) solid var(--hh-border);
}
.hh-modal:has(.hh-dup) { max-width: 880px; }
.hh-dup-cols { align-items: flex-start; }
.hh-dup-col { flex: 1 1 16rem; min-width: 0; }
.hh-dup-preview, .hh-invoice-preview {
  width: 100%; object-fit: contain;
  border: var(--hh-rule) solid var(--hh-border); background: var(--hh-surface-2);
}
.hh-dup-preview { max-height: 42vh; }
.hh-modal:has(.hh-invoice-preview) { max-width: 760px; }
.hh-invoice-preview { height: auto; max-height: 60vh; }
embed.hh-invoice-preview { height: 60vh; }

/* ---------- Drawer ---------- */
.hh-drawer-backdrop {
  position: fixed; inset: 0; background: var(--hh-overlay);
  z-index: var(--hh-z-modal-backdrop); display: none;
  opacity: 0; transition: opacity var(--hh-dur) var(--hh-ease-out);
}
.hh-drawer-backdrop[data-open="true"] { display: block; opacity: 1; }
.hh-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(400px, 100vw); display: flex; flex-direction: column;
  background: var(--hh-surface); border-left: var(--hh-rule) solid var(--hh-ink);
  box-shadow: var(--hh-shadow-lg); z-index: var(--hh-z-modal);
  transform: translateX(100%);
  transition: transform var(--hh-dur) var(--hh-ease-out);
}
.hh-drawer-backdrop[data-open="true"] .hh-drawer { transform: none; }
.hh-drawer__head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  gap: var(--hh-space-3); padding: var(--hh-space-4) var(--hh-space-5);
  border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-drawer__title { font-size: var(--hh-fs-3); font-weight: 700; }
.hh-drawer__body { flex: 1 1 auto; overflow-y: auto; padding: var(--hh-space-5); }

/* ---------- Connections ---------- */
.hh-iconbtn-badged { position: relative; }
.hh-count {
  position: absolute; top: 3px; right: 3px;
  min-width: 1.1rem; height: 1.1rem; padding: 0 0.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--hh-accent); color: var(--hh-accent-ink);
  font-size: var(--hh-fs-1); font-weight: 700; line-height: 1; pointer-events: none;
}
.hh-count--empty { display: none; }
.hh-conn-invite { margin-bottom: var(--hh-space-6); }
.hh-conn-invite__row { display: flex; gap: var(--hh-space-2); margin-top: var(--hh-space-2); }
.hh-conn-invite__row .hh-input { flex: 1 1 auto; min-width: 0; }
.hh-conn-invite__note { font-size: var(--hh-fs-1); margin-top: var(--hh-space-2); }
.hh-conn-invite__note--ok { color: var(--hh-ink); }
.hh-conn-invite__note--error { color: var(--hh-danger); }
.hh-conn-section + .hh-conn-section { margin-top: var(--hh-space-6); }
.hh-conn-section__title {
  display: flex; align-items: center; gap: var(--hh-space-2);
  font-size: var(--hh-fs-2); font-weight: 700;
  padding-top: var(--hh-space-2); margin-bottom: var(--hh-space-1);
  border-top: var(--hh-rule-heavy) solid var(--hh-rule-color);
}
.hh-conn-blank { padding: var(--hh-space-3) 0; }
.hh-conn {
  display: flex; align-items: center; gap: var(--hh-space-3);
  padding: var(--hh-space-3) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-conn__id { flex: 1 1 auto; min-width: 0; }
.hh-conn__name {
  display: flex; align-items: center; gap: var(--hh-space-2); flex-wrap: wrap;
  font-weight: 600; color: var(--hh-ink);
}
.hh-conn__meta { font-size: var(--hh-fs-1); color: var(--hh-ink-soft); margin-top: 2px; }
.hh-conn__actions { flex: none; display: flex; align-items: center; gap: var(--hh-space-1); }
.hh-conn-page { max-width: 46rem; }

/* ---------- Receipts: project field + view switch ---------- */
.hh-projbar { display: flex; flex-direction: column; gap: var(--hh-space-1); }
.hh-projbar__row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--hh-space-1) var(--hh-space-4); }
.hh-projbar__label { font-size: var(--hh-fs-3); color: var(--hh-muted); font-weight: 500; margin-right: calc(-1 * var(--hh-space-2)); }
.hh-projchip {
  display: inline-flex; align-items: center; gap: var(--hh-space-2);
  font-size: var(--hh-fs-3); font-weight: 700; letter-spacing: -0.01em; color: var(--hh-ink);
  padding: 0; height: 32px; cursor: pointer;
}
.hh-projchip:hover .hh-projchip__name { text-decoration: underline; text-underline-offset: 0.18em; }
.hh-projchip__name { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-context {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: var(--hh-space-4) var(--hh-space-6); margin-bottom: var(--hh-space-6);
}

/* Segmented switch — set as typographic tabs: the active view carries the red rule. */
.hh-segmented { display: inline-flex; gap: var(--hh-space-5); }
.hh-segmented__opt {
  display: inline-flex; align-items: center; height: 32px;
  font-size: var(--hh-fs-3); font-weight: 500; color: var(--hh-muted);
  box-shadow: inset 0 -2px 0 transparent;
}
.hh-segmented__opt:hover { color: var(--hh-ink); }
.hh-segmented__opt.is-active { color: var(--hh-ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--hh-accent); }
.hh-segmented--title { gap: var(--hh-space-6); }
.hh-segmented--title .hh-segmented__opt {
  height: auto; padding-bottom: var(--hh-space-1);
  font-size: var(--hh-fs-4); font-weight: 700; letter-spacing: -0.025em; line-height: 1.1;
  box-shadow: inset 0 -3px 0 transparent;
}
.hh-segmented--title .hh-segmented__opt.is-active { box-shadow: inset 0 -3px 0 var(--hh-accent); }
.hh-viewbar {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: var(--hh-space-3); margin-bottom: var(--hh-space-3);
}

/* ---------- Manager table (§5) ---------- */
.hh-toolbar {
  display: flex; flex-wrap: wrap; gap: var(--hh-space-2); align-items: center;
  margin-bottom: var(--hh-space-4);
}
.hh-toolbar .hh-select, .hh-toolbar .hh-input { width: auto; max-width: 14rem; }
.hh-search { position: relative; flex: 1 1 220px; max-width: 320px; }
.hh-toolbar .hh-search .hh-input { width: 100%; max-width: none; padding-left: 2rem; }
.hh-search__icon { position: absolute; left: 0.6rem; top: 50%; transform: translateY(-50%); color: var(--hh-muted); display: inline-flex; }

.hh-table-wrap {
  position: relative;               /* keeps sr-only labels inside the scroller */
  border-top: var(--hh-rule-heavy) solid var(--hh-rule-color);
  overflow-x: auto;
}
.hh-table-wrap--plain { border-top: 0; }
.hh-table { width: 100%; border-collapse: collapse; }
.hh-table th, .hh-table td { text-align: left; }
.hh-table thead th {
  font-size: var(--hh-fs-1); font-weight: 600; color: var(--hh-ink-soft); white-space: nowrap;
  padding: var(--hh-space-2) var(--hh-space-3);
  border-bottom: var(--hh-rule) solid var(--hh-ink);
}
.hh-table tbody td { padding: 0.65rem var(--hh-space-3); border-bottom: var(--hh-rule) solid var(--hh-border); vertical-align: middle; }
.hh-table th:first-child, .hh-table td:first-child { padding-left: 0; }
.hh-table th:last-child, .hh-table td:last-child { padding-right: 0; }
.hh-table tbody tr { transition: background var(--hh-dur-fast) var(--hh-ease-out); }
.hh-table tbody tr:hover { background: var(--hh-surface-2); }
.hh-table tbody tr[data-href] { cursor: pointer; }
.hh-table .hh-num { text-align: right; white-space: nowrap; }
.hh-table thead th.hh-num .hh-th__sort { flex-direction: row-reverse; }
.hh-table__actions { text-align: right; white-space: nowrap; width: 1%; }
.hh-table td.hh-table__actions, .hh-table th.hh-table__actions {
  position: sticky; right: 0; background: var(--hh-surface);
  padding-left: var(--hh-space-3);
}
.hh-table tbody tr:hover td.hh-table__actions { background: var(--hh-surface-2); }
/* row actions are quiet words, not the loudest thing in the row */
.hh-table .hh-btn--subtle { color: var(--hh-ink-soft); font-weight: 500; }
.hh-table .hh-btn--subtle:hover { color: var(--hh-ink); }
.hh-row-actions { display: inline-flex; gap: var(--hh-space-1); justify-content: flex-end; align-items: center; }
.hh-row-actions__danger:hover { color: var(--hh-danger); }
/* Key/value table (a record's fields). */
.hh-table--kv tbody th {
  width: 12rem; vertical-align: top; white-space: nowrap;
  padding: 0.65rem var(--hh-space-3) 0.65rem 0; font-weight: 500; color: var(--hh-ink-soft);
  border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-table--kv tbody tr:hover { background: transparent; }

.hh-table thead th.hh-th--sortable { padding: 0; }
.hh-th__sort {
  display: flex; align-items: center; gap: var(--hh-space-1);
  width: 100%; padding: var(--hh-space-2) var(--hh-space-3); color: inherit; cursor: pointer;
}
.hh-table thead th:first-child .hh-th__sort { padding-left: 0; }
.hh-th__sort:hover { color: var(--hh-ink); }
.hh-sort-ind { font-size: 0.7em; line-height: 1; opacity: 0; }
.hh-th__sort:hover .hh-sort-ind { opacity: 0.4; }
.hh-table thead th.hh-th--asc, .hh-table thead th.hh-th--desc { color: var(--hh-ink); }
.hh-table thead th.hh-th--asc .hh-sort-ind, .hh-table thead th.hh-th--desc .hh-sort-ind { opacity: 1; color: var(--hh-accent); }

/* Bulk-editable header — a "B" hint inks in on hover/focus; press B to bulk-edit. */
.hh-table thead th.hh-th--bulk { position: relative; }
.hh-table thead th.hh-th--bulk::after {
  content: "B"; position: absolute; top: 50%; right: var(--hh-space-1); transform: translateY(-50%);
  display: grid; place-items: center; width: 1.1rem; height: 1.1rem;
  font-size: var(--hh-fs-1); font-weight: 700; line-height: 1;
  color: var(--hh-surface); background: var(--hh-ink);
  opacity: 0; transition: opacity var(--hh-dur-fast) var(--hh-ease-out); pointer-events: none;
}
.hh-table thead th.hh-th--bulk:hover::after, .hh-table thead th.hh-th--bulk:focus-within::after { opacity: 1; }
.hh-table thead th.hh-th--bulk.hh-th--sortable .hh-th__sort { padding-right: 1.6rem; }
.hh-table thead th.hh-th--bulk:not(.hh-th--sortable) { padding-right: 1.6rem; }

/* List summary — a line of figures above the table. */
.hh-list-summary {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: var(--hh-space-2) var(--hh-space-6);
  margin-bottom: var(--hh-space-4);
}
.hh-list-summary__stat { display: flex; align-items: baseline; gap: var(--hh-space-2); }
.hh-list-summary__value { font-size: var(--hh-fs-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.hh-list-summary__label { font-size: var(--hh-fs-1); color: var(--hh-ink-soft); }

.hh-pager { display: flex; align-items: center; gap: var(--hh-space-3); margin-top: var(--hh-space-4); }

/* ---------- Inline click-to-edit ---------- */
.hh-ie-slot { display: inline-flex; align-items: center; max-width: 100%; }
.hh-ie-slot--block { display: flex; width: 100%; }
.hh-ie-sep { color: var(--hh-muted); margin: 0 var(--hh-space-2); }
.hh-ie {
  font: inherit; color: inherit; text-align: left; cursor: text;
  border-bottom: var(--hh-rule) dashed transparent;
  padding: 0.1rem 0; transition: border-color var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-ie:hover, .hh-ie:focus-visible { border-bottom-color: var(--hh-ink-soft); outline: none; }
.hh-ie--empty { color: var(--hh-muted); }
.hh-ie__input {
  font: inherit; width: 100%; min-width: 8rem; max-width: 22rem; padding: 0.2rem 0.45rem;
  background: var(--hh-surface); color: var(--hh-ink);
  border: var(--hh-rule) solid var(--hh-ink); box-shadow: inset 0 0 0 1px var(--hh-ink); outline: none;
}
.hh-ie__input--num { max-width: 10rem; }
textarea.hh-ie__input { min-height: 4rem; resize: vertical; }
.hh-ie__err { display: block; color: var(--hh-danger); font-size: var(--hh-fs-1); margin-top: 0.2rem; }
@keyframes hh-ie-saved { from { background: var(--hh-surface-3); } to { background: transparent; } }
.hh-ie--saved, .hh-kw--saved { animation: hh-ie-saved 0.9s var(--hh-ease-out); }

/* ---------- Keyword tags ---------- */
.hh-tag {
  display: inline-flex; align-items: center; padding: 0 0.4rem; min-height: 1.35rem;
  font-size: var(--hh-fs-1); background: var(--hh-surface-3); color: var(--hh-ink); white-space: nowrap;
}
.hh-kw {
  display: inline-flex; flex-wrap: wrap; gap: 0.25rem; align-items: center;
  padding: 0.1rem 0; cursor: pointer; text-align: left;
}
.hh-kw:hover:not([disabled]) .hh-tag, .hh-kw:hover:not([disabled]).hh-kw--empty { text-decoration: underline; }
.hh-kw[disabled] { cursor: default; }
.hh-kw--empty { color: var(--hh-muted); }
/* a person named in a split: plain text, separated by a middle dot */
.hh-person { white-space: nowrap; }
.hh-person + .hh-person::before { content: "·"; margin-right: 0.25rem; color: var(--hh-muted); }
.hh-kw-edit { display: inline-flex; gap: 0.3rem; align-items: flex-start; min-width: 13rem; }
.hh-kw-edit .ts-wrapper { min-width: 9rem; flex: 1; }

/* ---------- Empty states ---------- */
.hh-empty { padding: var(--hh-space-8) 0; color: var(--hh-ink-soft); border-top: var(--hh-rule) solid var(--hh-border); }
.hh-empty p:first-of-type { color: var(--hh-ink); font-size: var(--hh-fs-3); font-weight: 700; }
.hh-empty__mark { display: none; }

/* ---------- Tabs (ops panel) ---------- */
.hh-tabs {
  display: flex; gap: var(--hh-space-5); border-bottom: var(--hh-rule) solid var(--hh-border);
  margin-bottom: var(--hh-space-5); overflow-x: auto; scrollbar-width: none;
}
.hh-tabs::-webkit-scrollbar { display: none; }
.hh-tab {
  padding: var(--hh-space-3) 0; color: var(--hh-ink-soft); font-weight: 500;
  white-space: nowrap; box-shadow: inset 0 -2px 0 transparent;
}
.hh-tab:hover { color: var(--hh-ink); }
.hh-tab--active { color: var(--hh-ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--hh-accent); }

/* ---------- Auth pages: a form set flush left on the grid ---------- */
.hh-auth { min-height: var(--hh-main-fill); display: grid; align-content: center; padding: var(--hh-space-6) 0; }
.hh-auth__card { width: 100%; max-width: 400px; }
.hh-auth__card .hh-panel__body { padding: var(--hh-space-5) 0 0; }

.hh-chipstrip { display: flex; flex-wrap: wrap; gap: var(--hh-space-2); margin-bottom: var(--hh-space-4); }
.hh-account { display: flex; flex-direction: column; gap: var(--hh-space-6); max-width: 640px; }
.hh-form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--hh-space-4); }

/* ---------- Landing ---------- */
.hh-seams { margin-top: var(--hh-space-8); max-width: 760px; }
.hh-seams__lead { color: var(--hh-ink-soft); font-size: var(--hh-fs-3); margin-bottom: var(--hh-space-4); }
.hh-seams__list { border-top: var(--hh-rule-heavy) solid var(--hh-rule-color); }
.hh-seams__row {
  display: grid; grid-template-columns: 14rem 1fr; gap: var(--hh-space-5);
  padding: var(--hh-space-4) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-seams__row dt { display: flex; align-items: center; gap: var(--hh-space-2); font-weight: 700; }
.hh-seams__row dd { color: var(--hh-ink-soft); }
.hh-seams__idx { font-weight: 700; color: var(--hh-accent); font-variant-numeric: tabular-nums; }
.hh-seams__row--lead dt { font-size: var(--hh-fs-3); }
.hh-seams__row--lead dd { color: var(--hh-ink); }

/* ---------- Style guide ---------- */
.hh-sg__section { margin-bottom: var(--hh-space-8); }
.hh-sg__demo { padding: var(--hh-space-5) 0; border-top: var(--hh-rule) solid var(--hh-border); }
.hh-sg__code {
  margin-top: var(--hh-space-2); padding: var(--hh-space-3) var(--hh-space-4);
  background: var(--hh-surface-2); font-family: var(--hh-font-mono); font-size: var(--hh-fs-1);
  color: var(--hh-ink-soft); white-space: pre-wrap; overflow-x: auto;
}
.hh-swatch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--hh-space-3); }
.hh-swatch { border: var(--hh-rule) solid var(--hh-border); }
.hh-swatch__chip { height: 56px; }
.hh-swatch__label { padding: var(--hh-space-2) var(--hh-space-3); font-size: var(--hh-fs-1); font-family: var(--hh-font-mono); }

/* ---------- Object / entity chips (§2.4.1) ---------- */
.hh-chip, .hh-chip--object {
  display: inline-flex; align-items: center; gap: 0.35rem;
  height: 28px; padding: 0 0.5rem 0 0.25rem;
  border: var(--hh-rule) solid var(--hh-border-strong);
  font-size: var(--hh-fs-2); color: var(--hh-ink); position: relative;
}
.hh-chip:hover, .hh-chip--object:hover { border-color: var(--hh-ink); }
.hh-chip--object { padding-left: 0.6rem; }
.hh-chip__avatar {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--hh-fs-1); font-weight: 700; color: var(--hh-surface); background: var(--hh-ink); flex-shrink: 0;
}
.hh-chip__name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-chip__divider { width: 1px; height: 14px; background: var(--hh-border); margin: 0 2px; }
.hh-chip__btn {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--hh-muted); font-size: var(--hh-fs-1);
}
.hh-chip__btn:hover { background: var(--hh-surface-3); color: var(--hh-ink); }
.hh-chip__btn--remove:hover { color: var(--hh-danger); }
.hh-chip--add {
  display: inline-flex; align-items: center; gap: 0.35rem; height: 28px; padding: 0 0.6rem;
  border: var(--hh-rule) dashed var(--hh-border-strong); color: var(--hh-ink-soft);
}
.hh-chip--add:hover { border-color: var(--hh-ink); color: var(--hh-ink); }
.hh-chip-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px;
  background: var(--hh-surface); border: var(--hh-rule) solid var(--hh-ink);
  box-shadow: var(--hh-shadow-lg); padding: var(--hh-space-1) 0; z-index: var(--hh-z-dropdown); display: none;
}
.hh-chip-menu.is-open { display: block; }

/* ---------- Tom Select bridge ---------- */
.ts-dropdown { z-index: var(--hh-z-modal); }
.ts-wrapper.single .ts-control, .ts-wrapper.multi .ts-control {
  background: var(--hh-surface) !important; border-color: var(--hh-border-strong) !important;
  border-radius: 0 !important; color: var(--hh-ink) !important; box-shadow: none !important;
  min-height: 36px;
}
.ts-control input, .ts-control input::placeholder { color: var(--hh-ink) !important; }
.ts-control input::placeholder { color: var(--hh-muted) !important; }
.ts-wrapper.focus .ts-control { border-color: var(--hh-ink) !important; box-shadow: inset 0 0 0 1px var(--hh-ink) !important; }
.ts-dropdown {
  background: var(--hh-surface); border: var(--hh-rule) solid var(--hh-ink); color: var(--hh-ink);
  border-radius: 0; box-shadow: var(--hh-shadow-lg);
}
.ts-dropdown .option { color: var(--hh-ink); }
.ts-dropdown .option.active { background: var(--hh-surface-3); color: var(--hh-ink); }
.ts-dropdown .option:hover { background: var(--hh-surface-2); }
.ts-control .item { background: var(--hh-surface-3) !important; color: var(--hh-ink) !important; border-radius: 0 !important; border: 0 !important; }

/* ---------- Checkbox-gated reveal (no JS; uses :has()) ---------- */
.hh-reveal__body { display: grid; gap: var(--hh-space-4); }
.hh-reveal:has(.hh-reveal__toggle input:not(:checked)) .hh-reveal__body { display: none; }

/* ---------- Disclosure ---------- */
.hh-disclosure { margin-top: var(--hh-space-5); border-top: var(--hh-rule) solid var(--hh-border); padding-top: var(--hh-space-2); }
.hh-disclosure > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: var(--hh-space-2);
  padding: var(--hh-space-2) 0; font-weight: 600; color: var(--hh-ink);
}
.hh-disclosure > summary::-webkit-details-marker { display: none; }
.hh-disclosure > summary::before { content: "+"; width: 1ch; font-weight: 700; color: var(--hh-accent); }
.hh-disclosure[open] > summary::before { content: "–"; }
.hh-disclosure__body { padding-top: var(--hh-space-3); }
details > summary.hh-small { cursor: pointer; }

/* ---------- Upload drop zone ---------- */
.hh-dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--hh-space-2); padding: var(--hh-space-8) var(--hh-space-4); text-align: center;
  border: var(--hh-rule) dashed var(--hh-border-strong); color: var(--hh-ink-soft); cursor: pointer;
  transition: border-color var(--hh-dur-fast) var(--hh-ease-out), background var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-dropzone:hover, .hh-dropzone:focus-within, .hh-dropzone.is-dragover { border-color: var(--hh-ink); border-style: solid; background: var(--hh-surface-2); }
.hh-dropzone.has-file { border-style: solid; border-color: var(--hh-ink); color: var(--hh-ink); }
.hh-dropzone__mark { font-size: var(--hh-fs-4); font-weight: 300; line-height: 1; color: var(--hh-ink); }
.hh-dropzone__text { font-size: var(--hh-fs-2); }
.hh-dropzone__file { display: none; max-width: 100%; font-weight: 700; color: var(--hh-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-dropzone.has-file .hh-dropzone__file { display: block; }
.hh-dropzone.has-file .hh-dropzone__text { display: none; }
.hh-dropzone input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.hh-extract-loading { display: none; align-items: center; justify-content: center; gap: var(--hh-space-2); padding: var(--hh-space-4); color: var(--hh-ink-soft); }
form.htmx-request .hh-extract-loading { display: flex; }
form.htmx-request .hh-dropzone { opacity: 0.5; pointer-events: none; }

.hh-visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hh-code {
  font-family: var(--hh-font-mono); font-size: var(--hh-fs-1);
  background: var(--hh-surface-2); padding: var(--hh-space-3); overflow: auto; max-height: 24rem;
}
.ai-pricing-refresh__busy { display: none; }
.ai-pricing-refresh.htmx-request .ai-pricing-refresh__idle { display: none; }
.ai-pricing-refresh.htmx-request .ai-pricing-refresh__busy { display: inline; }

/* ---------- Figures: a number over its label, no tile ---------- */
.hh-stats-controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--hh-space-4);
  margin: 0 0 var(--hh-space-5);
}
.hh-stats-controls__field { display: flex; flex-direction: column; gap: var(--hh-space-1); }
.hh-stats-controls__field .hh-select { min-width: 16rem; }
.hh-stats-controls__toggle { border-bottom: 0; margin-bottom: 0; }
.hh-stats-grid {
  display: grid; gap: var(--hh-space-5);
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  margin-bottom: var(--hh-space-4);
}
.hh-stat, .hh-year-card {
  display: flex; flex-direction: column; gap: var(--hh-space-1);
  padding-top: var(--hh-space-2); border-top: var(--hh-rule) solid var(--hh-ink);
}
.hh-stat__value { font-size: var(--hh-fs-4); font-weight: 700; line-height: 1.05; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hh-stat__unit { font-size: var(--hh-fs-2); font-weight: 600; color: var(--hh-ink-soft); letter-spacing: 0; }
.hh-stat__label { font-size: var(--hh-fs-1); color: var(--hh-ink-soft); }
.hh-year-grid { display: grid; gap: var(--hh-space-5); grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
.hh-year-card__year { font-size: var(--hh-fs-2); font-weight: 700; }
.hh-year-card__money { display: flex; flex-direction: column; gap: 2px; }
.hh-year-card__amount { font-size: var(--hh-fs-3); font-weight: 700; font-variant-numeric: tabular-nums; }
.hh-year-card__meta { color: var(--hh-ink-soft); }

/* ---------- Sort mode: one item at a time ---------- */
.hh-sort-shell {
  position: relative; min-height: var(--hh-main-fill);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--hh-space-5); padding: var(--hh-space-6) 0 var(--hh-space-4); text-align: center;
}
.hh-sort-exit { position: absolute; top: 0; right: 0; }
.hh-sort-start { max-width: 44rem; width: 100%; display: flex; flex-direction: column; gap: var(--hh-space-2); align-items: flex-start; text-align: left; }
.hh-sort-start__title { font-size: var(--hh-fs-4); font-weight: 700; letter-spacing: -0.025em; }
.hh-sort-start__count { font-size: var(--hh-fs-3); margin-top: var(--hh-space-2); }
.hh-sort-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--hh-space-5);
  width: 100%; margin-top: var(--hh-space-5);
}
.hh-sort-choice {
  display: flex; flex-direction: column; gap: var(--hh-space-1); align-items: flex-start; text-align: left;
  padding: var(--hh-space-3) 0 var(--hh-space-4);
  border-top: var(--hh-rule-heavy) solid var(--hh-rule-color); color: var(--hh-ink);
}
.hh-sort-choice:hover .hh-sort-choice__name { color: var(--hh-accent); }
.hh-sort-choice__mark { display: none; }
.hh-sort-choice__name { font-size: var(--hh-fs-3); font-weight: 700; }
.hh-sort-choice__hint { color: var(--hh-ink-soft); }

.hh-sort-head { width: min(34rem, 92vw); display: flex; flex-direction: column; gap: var(--hh-space-2); }
.hh-sort-progress { height: 2px; background: var(--hh-surface-3); overflow: hidden; }
.hh-sort-progress > span { display: block; height: 100%; width: 0; background: var(--hh-ink); }
.hh-sort-stage { display: flex; align-items: center; gap: var(--hh-space-4); }
.hh-sort-card {
  position: relative; width: min(30rem, 84vw); min-height: 13rem;
  display: flex; flex-direction: column; gap: var(--hh-space-2); align-items: flex-start; justify-content: center;
  padding: var(--hh-space-5) 0; text-align: left;
  border-top: 4px solid var(--hh-ink); border-bottom: var(--hh-rule) solid var(--hh-border);
  transition: transform var(--hh-dur) var(--hh-ease-out), opacity var(--hh-dur) var(--hh-ease-out);
}
.hh-sort-card.is-out { transform: translateX(-24px); opacity: 0; }
.hh-sort-card.is-sorted { opacity: 0.55; }
.hh-sort-card.is-error { border-top-color: var(--hh-danger); animation: hh-shake 0.4s var(--hh-ease-out); }
.hh-sort-card__kicker { font-size: var(--hh-fs-1); color: var(--hh-ink-soft); font-weight: 600; }
.hh-sort-card__date { font-size: var(--hh-fs-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.hh-sort-card__desc { font-size: var(--hh-fs-4); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
.hh-sort-card__meta { color: var(--hh-ink-soft); font-variant-numeric: tabular-nums; }
.hh-sort-nav {
  flex: none; width: 2.5rem; height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; color: var(--hh-ink-soft); font-size: var(--hh-fs-3);
  border: var(--hh-rule) solid var(--hh-border-strong);
}
.hh-sort-nav:hover { color: var(--hh-ink); border-color: var(--hh-ink); }
.hh-sort-hint { margin: 0; }
.hh-sort-invoices { width: min(34rem, 92vw); display: flex; flex-direction: column; align-items: center; gap: var(--hh-space-2); }
.hh-sort-invoices > p { margin: 0; }
.hh-sort-invoices__list { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--hh-space-2); max-height: 7.5rem; overflow-y: auto; padding: 2px; }
.hh-chip.hh-sort-invoice-chip { height: 26px; padding: 0 0.6rem; font-size: var(--hh-fs-1); }
.hh-sort-invoice-chip__amount { color: var(--hh-muted); font-variant-numeric: tabular-nums; }
.hh-sort-legend { display: flex; flex-wrap: wrap; gap: var(--hh-space-4); justify-content: center; max-width: 44rem; }
.hh-keycap { display: flex; flex-direction: column; align-items: center; gap: var(--hh-space-1); color: var(--hh-ink-soft); cursor: pointer; }
.hh-keycap:hover { color: var(--hh-ink); }
.hh-keycap__key {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; border: var(--hh-rule) solid var(--hh-ink);
  font-weight: 700; color: var(--hh-ink); font-variant-numeric: tabular-nums;
  transition: background var(--hh-dur-fast) var(--hh-ease-out), color var(--hh-dur-fast) var(--hh-ease-out);
}
.hh-keycap:hover .hh-keycap__key, .hh-keycap:active .hh-keycap__key { background: var(--hh-ink); color: var(--hh-surface); }
.hh-keycap__label { font-size: var(--hh-fs-1); max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-sort-overflow { max-width: 28rem; }
.hh-sort-done { display: flex; flex-direction: column; align-items: center; gap: var(--hh-space-3); }
/* "N items still need splitters" — the line that needs you */
.hh-sort-cta { color: var(--hh-accent); font-weight: 700; }
.hh-sort-cta:hover { text-decoration: underline; text-underline-offset: 0.2em; }
@keyframes hh-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* =============================================================================
   Home: the balance as a sentence and one figure, then what is open, then
   what came in. Typeset, not tiled.
   ========================================================================== */
.hh-balance__line { font-size: var(--hh-fs-3); color: var(--hh-ink-soft); }
.hh-balance__line strong { color: var(--hh-ink); font-weight: 700; }
.hh-balance__amount {
  font-size: var(--hh-fs-5); font-weight: 700; letter-spacing: -0.035em; line-height: 1;
  font-variant-numeric: tabular-nums lining-nums; margin-top: var(--hh-space-2);
}
.hh-balance__people { margin-top: var(--hh-space-5); }
.hh-balance__row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: baseline; gap: var(--hh-space-4);
  padding: var(--hh-space-2) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-balance__row:first-child { border-top: var(--hh-rule) solid var(--hh-border); }
.hh-balance__who { font-weight: 600; }
.hh-balance__you { color: var(--hh-muted); font-weight: 500; }
.hh-balance__state { color: var(--hh-ink-soft); }
.hh-balance__sum { font-weight: 700; text-align: right; min-width: 8rem; font-variant-numeric: tabular-nums; }

.hh-due { display: flex; flex-direction: column; }
.hh-due__item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--hh-space-4);
  padding: var(--hh-space-3) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-due__title { font-size: var(--hh-fs-3); font-weight: 700; color: var(--hh-accent); }
.hh-due__sub { color: var(--hh-ink-soft); }
.hh-calm { color: var(--hh-ink-soft); padding: var(--hh-space-2) 0; }

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hh-sec--split { grid-template-columns: 1fr; gap: var(--hh-space-3); }
}
@media (max-width: 720px) {
  .hh-main { padding: var(--hh-space-5) var(--hh-space-4) var(--hh-space-8); }
  .hh-nav { gap: var(--hh-space-4); padding: 0 var(--hh-space-4); }
  .hh-brand__word, .hh-usermenu__name, .hh-nav__desk { display: none; }
  .hh-nav__links { gap: var(--hh-space-4); }
  .hh-actionbar__inner { padding: var(--hh-space-2) var(--hh-space-4); gap: var(--hh-space-2) var(--hh-space-4); }
  .hh-form-2col { grid-template-columns: 1fr; }
  .hh-seams__row { grid-template-columns: 1fr; gap: var(--hh-space-2); }
  .hh-sort-choices { grid-template-columns: 1fr; }
  .hh-actionbar__inner { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .hh-actionbar__inner > * { flex: none; }
  .hh-search { max-width: none; flex-basis: 100%; }
  .hh-table td.hh-table__actions, .hh-table th.hh-table__actions { position: relative; }
  .hh-table--kv tbody th { width: 7.5rem; white-space: normal; }
  .hh-table tbody td { padding: 0.6rem var(--hh-space-2); }
  .hh-segmented--title { gap: var(--hh-space-5); }
  /* a manager table restacks: the row's name and amount on one line, the rest beneath */
  .hh-table--stack thead { display: none; }
  .hh-table--stack, .hh-table--stack tbody { display: block; }
  .hh-table--stack tbody tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--hh-space-3);
    padding: var(--hh-space-3) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
  }
  .hh-table--stack tbody td { display: block; padding: 0; border: 0; grid-column: 1; font-size: var(--hh-fs-1); color: var(--hh-ink-soft); }
  .hh-table--stack tbody td.hh-col--lead { grid-row: 1; font-size: var(--hh-fs-2); font-weight: 600; color: var(--hh-ink); }
  .hh-table--stack tbody td.hh-num { grid-column: 2; grid-row: 1; font-size: var(--hh-fs-2); font-weight: 600; color: var(--hh-ink); }
  .hh-table--stack tbody td.hh-table__actions { grid-column: 2; grid-row: 2 / span 3; align-self: end; padding: 0; background: transparent; }
  .hh-table--stack tbody tr > td + td:not(.hh-num):not(.hh-table__actions) { margin-top: 2px; }
  .hh-sec--split > .hh-sec__head { flex-direction: row; justify-content: space-between; align-items: baseline; margin-bottom: var(--hh-space-3); }
  .hh-due__item { grid-template-columns: 1fr; gap: var(--hh-space-3); }
  .hh-due__item .hh-btn { justify-self: start; }
  /* secondary table columns step aside on a phone; the row still opens */
  .hh-table .hh-col--secondary { display: none; }
  .hh-toolbar .hh-select { flex: 1 1 40%; max-width: none; min-width: 0; }
  .hh-balance__row { grid-template-columns: 1fr auto; }
  .hh-balance__state { display: none; }
}

/* =============================================================================
   Browser surfaces — the parts we did not draw still carry the design.
   ========================================================================== */
::selection { background: var(--hh-ink); color: var(--hh-surface); }
:root { accent-color: var(--hh-ink); caret-color: var(--hh-accent); }
* { scrollbar-color: var(--hh-border-strong) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hh-border-strong); border: 3px solid var(--hh-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--hh-muted); }
a { text-underline-offset: 0.18em; }
:focus-visible { outline: 2px solid var(--hh-ink); outline-offset: 2px; border-radius: 0; }

/* plain list: one line per entry, hairlines between */
.hh-list { list-style: none; padding: 0; margin: 0; }
.hh-list__row {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--hh-space-4);
  padding: var(--hh-space-2) 0; border-bottom: var(--hh-rule) solid var(--hh-border);
}
.hh-list__row a:hover, .hh-table--plain a:hover { text-decoration: underline; }

.hh-accent-text { color: var(--hh-accent); font-weight: 700; }
.hh-block-link { display: block; font-size: var(--hh-fs-3); margin: 0 0 var(--hh-space-6); }
.hh-table tfoot th { padding: var(--hh-space-2) var(--hh-space-3); border-top: var(--hh-rule) solid var(--hh-ink); font-weight: 700; text-align: left; }
.hh-table tfoot th:first-child { padding-left: 0; }
.hh-table tfoot th:last-child { padding-right: 0; }
