/* ── Typography ──────────────────────────────────────────────────────────
   Bricolage Grotesque (self-hosted, variable 600–700) for headings and the
   brand; body text stays on Pico's system stack. */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url('/static/fonts/bricolage-grotesque-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
h1, h2, h3, .brand .brand-name {
  font-family: 'Bricolage Grotesque', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0.005em;
}

/* Money and date columns line up digit-for-digit. */
.amount-in, .amount-out, .amount-transfer,
td.col-total, th.col-total, .tk-group-cell,
.tx-amt, .rc-item-num, table td[style*="text-align:right"] {
  font-variant-numeric: tabular-nums;
}

/* ── Kitty palette (drawn from the icon) ─────────────────────────────────
   cream page, sage green primary, terracotta accent, coin gold, warm ink */
[data-theme="light"], :root:not([data-theme="dark"]) {
  --kitty-sage: #6f8a55;
  --kitty-sage-dark: #59713F;
  --kitty-sage-tint: #e7ecdd;
  --kitty-terracotta: #b35c3e;
  --kitty-terracotta-dark: #9a4c31;
  --kitty-terracotta-tint: #f5e3da;
  --kitty-gold: #b9852e;
  --kitty-gold-dark: #8a6420; /* AA text on --kitty-gold-tint */
  --kitty-gold-tint: #f6ecd2;
  --kitty-cream: #faf5e9;
  --kitty-card: #fffdf7;
  --kitty-ink: #43392e;

  --pico-background-color: var(--kitty-cream);
  --pico-color: var(--kitty-ink);
  /* Darkened from #8a7d6b to clear WCAG AA 4.5:1 on the cream/card backgrounds. */
  --pico-muted-color: #74695a;
  --pico-muted-border-color: #e6dcc6;
  --pico-card-background-color: var(--kitty-card);
  --pico-card-border-color: #e6dcc6;
  --pico-card-sectioning-background-color: #f6efdf;
  --pico-form-element-background-color: #fffdf7;
  --pico-form-element-border-color: #d9cdb2;
  --pico-form-element-active-border-color: var(--kitty-sage);
  --pico-form-element-focus-color: rgba(111, 138, 85, 0.35);

  --pico-primary: var(--kitty-sage-dark);
  /* Filled primary buttons use the darker sage so white text clears 4.5:1
     (the lighter --kitty-sage only reached 3.85:1). */
  --pico-primary-background: var(--kitty-sage-dark);
  --pico-primary-border: var(--kitty-sage-dark);
  --pico-primary-hover: #4a5e34;
  --pico-primary-hover-background: var(--kitty-sage-dark);
  --pico-primary-hover-border: var(--kitty-sage-dark);
  --pico-primary-focus: rgba(111, 138, 85, 0.4);
  --pico-primary-underline: rgba(89, 113, 63, 0.5);
  --pico-primary-inverse: #fff;
  --pico-text-selection-color: rgba(111, 138, 85, 0.25);

  /* Darkened from #8a7d6b so outline-secondary text clears 4.5:1. */
  --pico-secondary: #6f6354;
  --pico-secondary-background: #6f6354;
  --pico-secondary-border: #6f6354;
  --pico-secondary-hover: #5c5145;
  --pico-secondary-hover-background: #5c5145;
  --pico-secondary-hover-border: #5c5145;
  --pico-secondary-focus: rgba(111, 99, 84, 0.35);
  --pico-secondary-inverse: #fff;
}

nav ul { margin: 0; padding: 0; }
body > header.container-fluid nav,
body > header.container-fluid nav ul { flex-wrap: wrap; }

/* ── Mobile navigation ───────────────────────────────────────────────── */
button.nav-toggle {
  display: none; width: auto; margin: 0; padding: 0.35rem;
  background: none; border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.4rem; color: var(--pico-muted-color); cursor: pointer;
  box-shadow: none; line-height: 0;
}
/* --kitty-ink, not --pico-color: Pico redefines --pico-color to white
   inside buttons, which would make the icon invisible. */
button.nav-toggle:hover,
button.nav-toggle[aria-expanded="true"] { color: var(--kitty-ink); border-color: var(--pico-secondary); }
@media (max-width: 860px) {
  button.nav-toggle { display: inline-flex; }
  body > header.container-fluid nav > ul.nav-menu { display: none; }
  body > header.container-fluid nav.nav-open > ul.nav-menu {
    display: flex; flex-direction: column; align-items: flex-start;
    width: 100%; gap: 0.1rem; padding: 0.6rem 0 0.3rem;
  }
  body > header.container-fluid nav.nav-open > ul.nav-menu > li { width: 100%; }
  body > header.container-fluid nav.nav-open > ul.nav-menu a:not(.brand) {
    display: block; padding: 0.45rem 0.25rem; border-bottom: 0;
  }
  body > header.container-fluid nav.nav-open > ul.nav-menu a.nav-active {
    border-left: 3px solid var(--kitty-terracotta); padding-left: 0.5rem;
  }
}

/* Subtle, consistent transitions on interactive chrome. */
a, button, [role="button"], input, select, textarea, summary, .tk-chip, .badge, .tx-acct-badge {
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

/* Primary nav links: muted by default, branded + underlined when active. */
body > header.container-fluid nav > ul { gap: 0.2rem 0.85rem; align-items: center; }
body > header.container-fluid nav > ul > li { padding: 0; }
body > header.container-fluid nav a:not(.brand) {
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
  color: var(--pico-muted-color);
  /* margin 0 cancels Pico's negative nav-link margins so links and the
     dropdown summaries (which have none) space evenly from the flex gap */
  margin: 0; padding: 0.3rem 0.15rem; border-bottom: 2px solid transparent;
}
body > header.container-fluid nav a:not(.brand):hover { color: var(--kitty-terracotta); }
body > header.container-fluid nav a.nav-active {
  color: var(--kitty-terracotta); border-bottom-color: var(--kitty-terracotta);
}
/* The financial-year selector starts the right-hand cluster (FY + gear);
   when the read-only badge is visible it leads the cluster instead. */
body > header.container-fluid nav li.fy-select-li { margin-left: auto; }
body > header.container-fluid nav #readonly-badge:not([hidden]) { margin-left: auto; }
body > header.container-fluid nav #readonly-badge:not([hidden]) ~ li.fy-select-li { margin-left: 0; }

/* ── Nav dropdowns (Hall hire / Banking / gear menu) ─────────────────── */
nav details.nav-dd { position: relative; margin: 0; display: inline-flex; }
nav details.nav-dd > summary {
  display: inline-flex; align-items: center; gap: 0.28rem;
  margin: 0; padding: 0.3rem 0.15rem; line-height: inherit;
  font-size: 0.9rem; font-weight: 600; color: var(--pico-muted-color);
  border-bottom: 2px solid transparent; cursor: pointer; user-select: none;
  list-style: none;
}
nav details.nav-dd > summary::after { display: none; }  /* Pico's accordion chevron */
nav details.nav-dd > summary::-webkit-details-marker { display: none; }
nav details.nav-dd > summary:hover,
nav details.nav-dd[open] > summary { color: var(--kitty-terracotta); }
/* Parent lights up when the current page lives inside it (see kitty.js). */
nav details.nav-dd > summary.nav-active {
  color: var(--kitty-terracotta); border-bottom-color: var(--kitty-terracotta);
}
.nav-caret { width: 0.62em; height: 0.62em; flex-shrink: 0; opacity: 0.7; transition: transform 0.15s ease; }
nav details.nav-dd[open] > summary .nav-caret { transform: rotate(180deg); }
nav details.nav-dd > ul.nav-dd-menu {
  position: absolute; top: calc(100% + 0.45rem); left: -0.4rem; z-index: 1000;
  display: flex; flex-direction: column; min-width: 10.5rem;
  margin: 0; padding: 0.3rem;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 0.4rem 1.2rem rgba(43, 36, 28, 0.16);
}
nav details.nav-dd.nav-dd-right > ul.nav-dd-menu { left: auto; right: -0.4rem; }
nav .nav-dd-menu > li { width: 100%; margin: 0; padding: 0; list-style: none; }
body > header.container-fluid nav .nav-dd-menu a:not(.brand) {
  /* margin 0 cancels Pico's negative nav-link margins, which would otherwise
     pull rows over the menu's padding and each other */
  display: block; margin: 0; padding: 0.42rem 0.65rem;
  border-bottom: 0; border-radius: 0.35rem;
  font-size: 0.88rem; color: var(--kitty-ink);
}
body > header.container-fluid nav .nav-dd-menu a:not(.brand):hover { background: var(--kitty-sage-tint); color: var(--kitty-ink); }
body > header.container-fluid nav .nav-dd-menu a.nav-active { color: var(--kitty-terracotta); background: var(--kitty-terracotta-tint); }
nav .nav-dd-menu li.nav-dd-sep {
  border-top: 1px solid var(--pico-muted-border-color); margin: 0.25rem 0.3rem;
  width: auto; height: 0; line-height: 0; overflow: hidden;
}
nav .nav-dd-menu form { margin: 0; }
button.nav-dd-btn {
  display: block; width: 100%; margin: 0; padding: 0.42rem 0.65rem;
  font-size: 0.88rem; font-weight: 600; text-align: left; line-height: inherit;
  background: none; border: 0; border-radius: 0.35rem;
  color: var(--kitty-ink); cursor: pointer; box-shadow: none;
}
button.nav-dd-btn:hover { background: var(--kitty-sage-tint); color: var(--kitty-ink); box-shadow: none; }
/* Gear trigger: quiet icon button to match the FY selector's height */
nav details.nav-dd > summary.nav-gear {
  padding: 0.32rem 0.5rem; border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.4rem; border-bottom-width: 1px;
}
nav details.nav-dd > summary.nav-gear .icon { width: 1.05em; height: 1.05em; }
nav details.nav-dd > summary.nav-gear:hover,
nav details.nav-dd[open] > summary.nav-gear { color: var(--kitty-ink); border-color: var(--pico-secondary); }
nav details.nav-dd > summary.nav-gear.nav-active { color: var(--kitty-terracotta); border-bottom-color: var(--pico-muted-border-color); }
.nav-gear-label { display: none; }
/* On mobile the dropdown groups flatten into labelled sections inside the
   hamburger menu (kitty.js opens them whenever the menu opens). Must come
   after the desktop dropdown rules above to override them. */
@media (max-width: 860px) {
  nav details.nav-dd { display: block; width: 100%; position: static; }
  nav details.nav-dd > summary {
    pointer-events: none; margin: 0; padding: 0.55rem 0.25rem 0.1rem;
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--pico-muted-color); border-bottom: 0;
  }
  nav details.nav-dd[open] > summary,
  nav details.nav-dd > summary.nav-active,
  nav details.nav-dd > summary.nav-gear.nav-active { color: var(--pico-muted-color); border-bottom: 0; }
  nav details.nav-dd > summary .nav-caret { display: none; }
  nav details.nav-dd > ul.nav-dd-menu {
    position: static; min-width: 0; padding: 0;
    background: none; border: 0; box-shadow: none; border-radius: 0;
  }
  body > header.container-fluid nav .nav-dd-menu a:not(.brand) {
    display: block; margin: 0; padding: 0.45rem 0.25rem; border-radius: 0;
    color: var(--pico-muted-color); font-size: inherit; background: none;
  }
  body > header.container-fluid nav .nav-dd-menu a.nav-active {
    color: var(--kitty-terracotta); background: none;
    border-left: 3px solid var(--kitty-terracotta); padding-left: 0.5rem;
  }
  nav details.nav-dd > summary.nav-gear { border: 0; padding: 0.55rem 0.25rem 0.1rem; }
  nav details.nav-dd > summary.nav-gear .icon,
  nav details.nav-dd > summary.nav-gear .nav-caret { display: none; }
  .nav-gear-label { display: inline; }
  button.nav-dd-btn {
    border-radius: 0; margin: 0; padding: 0.45rem 0.25rem;
    color: var(--pico-muted-color); width: auto;
  }
  button.nav-dd-btn:hover { background: none; color: var(--kitty-ink); }
  nav .nav-dd-menu li.nav-dd-sep { display: none; }
  body > header.container-fluid nav li.fy-select-li { margin-left: 0.25rem; padding: 0.45rem 0; }
  body > header.container-fluid nav #readonly-badge:not([hidden]) { margin-left: 0.25rem; padding: 0.35rem 0 0; }
}

/* Inline SVG icons (see _icons.html); scale with the surrounding text. */
svg.icon {
  width: 0.95em; height: 0.95em; display: inline-block;
  vertical-align: -0.12em; flex-shrink: 0;
}

/* Visually hidden, but available to screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Inline icon buttons (Pico buttons are full-width blocks by default) */
button.icon-btn {
  display: inline-block; width: auto; margin: 0;
  padding: 0.05rem 0.5rem; font-size: 0.8rem; line-height: 1.4;
}
button.icon-btn-danger { color: var(--kitty-terracotta); }

/* ── Brand header ────────────────────────────────────────────────────── */
body > header.container-fluid {
  background: var(--kitty-card);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-top: 0.45rem; padding-bottom: 0.45rem;
  margin-bottom: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand img { height: 2.4rem; width: 2.4rem; border-radius: 0.55rem; box-shadow: 0 1px 3px rgba(67, 57, 46, 0.18); }
.brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand .brand-name { font-size: 1.15rem; font-weight: 700; color: var(--kitty-terracotta); letter-spacing: 0.01em; }
.brand .brand-tag { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--pico-muted-color); }
.brand:hover .brand-name { color: var(--kitty-terracotta-dark); }

/* ── Global financial-year selector ──────────────────────────────────── */
.fy-select-li { display: inline-flex; align-items: center; }
select.fy-select {
  margin: 0; width: auto; min-width: 8.5rem;
  padding: 0.15rem 1.6rem 0.15rem 0.55rem;
  font-size: 0.8rem; font-weight: 600; min-height: 0; height: auto;
  line-height: 1.4; color: var(--kitty-sage-dark);
  background-color: var(--kitty-sage-tint);
  border-color: var(--pico-muted-border-color); border-radius: 0.4rem;
  background-position: center right 0.5rem; background-size: 0.65rem auto;
}
select.fy-select:focus { box-shadow: 0 0 0 0.15rem var(--pico-primary-focus); }

.amount-in  { color: var(--kitty-sage-dark); font-weight: 600; }
/* terracotta-dark: the base terracotta is 4.27:1 on cream, just under AA */
.amount-out { color: var(--kitty-terracotta-dark); font-weight: 600; }
.amount-transfer { color: #6b6157; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.15em 0.5em;
  border-radius: 0.3em;
  font-weight: 600;
}
.badge-income  { background: var(--kitty-sage-tint); color: var(--kitty-sage-dark); }
.badge-expense { background: var(--kitty-terracotta-tint); color: var(--kitty-terracotta-dark); }
.badge-uncategorised { background: var(--kitty-gold-tint); color: var(--kitty-gold-dark); }
.badge-processing { background: var(--kitty-sage-tint); color: var(--kitty-sage-dark); display: inline-flex; align-items: center; gap: 0.3em; }
.badge-spinner {
  display: inline-block; width: 0.7em; height: 0.7em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: rc-spin 0.7s linear infinite;
}
.split-total-error { color: var(--kitty-terracotta); font-size: 0.85rem; }

/* ── Accounts tree editor ────────────────────────────────────────────── */
#account-tree .acct-section {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-card-border-color);
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: 0.85rem;
}
#account-tree ul.acct-children {
  list-style: none;
  margin: 0;
  padding: 0.1rem 0 0.1rem 1.4rem;
  min-height: 0.45rem; /* droppable even when empty */
}
#account-tree li.acct-node { margin: 0; padding: 0; list-style: none; }
#account-tree li.acct-node::marker { content: ""; }
#account-tree .acct-row {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.18rem 0.3rem; border-radius: 0.3rem;
}
#account-tree .acct-row:hover { background: var(--kitty-sage-tint); }
#account-tree .acct-root-row { padding-left: 0; }
#account-tree .acct-root-row:hover { background: none; }
.acct-handle { cursor: grab; color: var(--pico-muted-color); font-size: 0.85rem; user-select: none; }
#account-tree .acct-actions {
  display: inline-flex; gap: 0.2rem; margin-left: auto;
  opacity: 0; transition: opacity 0.1s;
}
#account-tree .acct-row:hover .acct-actions,
#account-tree .acct-actions:focus-within { opacity: 1; }
#account-tree .sortable-ghost > .acct-row { background: var(--kitty-gold-tint); }

table { font-size: 0.9rem; }
th { white-space: nowrap; }
/* Compact transactions table — readable density, not spreadsheet-cramped */
table.tx-compact { font-size: 0.8rem; line-height: 1.3; border-collapse: collapse; }
table.tx-compact th,
table.tx-compact td { padding: 0.34rem 0.45rem; vertical-align: middle; }
table.tx-compact tr.tx-row { height: auto; }
/* Zebra striping for scanability; hover wins over the stripe. */
table.tx-compact tbody tr.tx-row:nth-of-type(even) td { background: rgba(111, 138, 85, 0.04); }
table.tx-compact tbody tr.tx-row:hover td { background: var(--kitty-sage-tint); }
table.tx-compact .tx-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tx-compact .tx-type-abbr { font-size: 0.72rem; opacity: 0.85; }
table.tx-compact .tx-desc { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
table.tx-compact .tx-th-notes { width: 14%; min-width: 5.5rem; max-width: 12rem; }
table.tx-compact .tx-notes { max-width: 12rem; }
table.tx-compact input.tx-row-notes,
table.tx-compact input.tx-row-category {
  margin: 0 !important;
  padding: 0.1rem 0.3rem !important;
  padding-block: 0.1rem !important;
  font-size: 0.78rem !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
  height: 1.55rem !important;
  box-sizing: border-box !important;
  width: 100%;
  max-width: 100%;
  /* Read as plain text until the user interacts — no grid of empty boxes. */
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  border-radius: 0.3rem;
}
table.tx-compact tr.tx-row:hover input.tx-row-notes,
table.tx-compact tr.tx-row:hover input.tx-row-category,
table.tx-compact input.tx-row-notes:hover,
table.tx-compact input.tx-row-category:hover {
  border-color: var(--pico-form-element-border-color) !important;
  background: var(--pico-card-background-color, #fff) !important;
}
table.tx-compact input.tx-row-notes:focus,
table.tx-compact input.tx-row-category:focus {
  border-color: var(--pico-form-element-active-border-color) !important;
  background: #fff !important;
  box-shadow: 0 0 0 0.12rem var(--pico-primary-focus) !important;
}
/* Quiet placeholders: invisible until the row is hovered or the field is
   focused, so a mostly-empty column doesn't read as a page of "Notes…". */
table.tx-compact input.tx-row-notes::placeholder,
table.tx-compact input.tx-row-category::placeholder { color: transparent; }
table.tx-compact tr.tx-row:hover input.tx-row-notes::placeholder,
table.tx-compact input.tx-row-notes:focus::placeholder,
table.tx-compact tr.tx-row:hover input.tx-row-category::placeholder,
table.tx-compact input.tx-row-category:focus::placeholder { color: var(--pico-muted-color); opacity: 0.7; }
table.tx-compact .tx-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Money out is the norm here, so keep it neutral ink — reserve colour for
   incoming credits (green). Stops the whole column reading as "errors". */
table.tx-compact .amount-out { color: var(--kitty-ink); font-weight: 500; }
table.tx-compact .tx-th-check, table.tx-compact .tx-th-rcpt { width: 1%; }
table.tx-compact .tx-th-date { width: 1%; }
table.tx-compact .tx-th-acct { width: 1%; }
table.tx-compact .tx-th-type { width: 1%; }
table.tx-compact .tx-acct-badge {
  display: inline-block;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: 0.35rem;
  line-height: 1.2;
}
table.tx-compact .tx-acct-current { background: var(--kitty-gold-tint); color: var(--kitty-gold-dark); }
table.tx-compact .tx-acct-savings { background: var(--kitty-sage-tint); color: var(--kitty-sage-dark); }
table.tx-compact .tx-th-amt { width: 1%; }
table.tx-compact .tx-th-cat { min-width: 7rem; }
table.tx-compact input.tx-check { margin: 0 !important; width: 0.95rem; height: 0.95rem; }
.tx-kbd-hint kbd {
  font-size: 0.68rem; padding: 0.02em 0.28em; border-radius: 0.2em;
  border: 1px solid var(--pico-muted-border-color, #ccc); background: var(--pico-card-background-color, #fff);
}
.tx-bulk-bar select { margin: 0 !important; padding: 0.15rem 0.35rem !important; font-size: 0.78rem !important; min-height: 0 !important; }
.tx-toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.35rem 1.25rem; margin: 0 0 0.4rem; }
.tx-toolbar details { margin: 0; padding: 0; border: 0; width: auto; }
.tx-toolbar details summary {
  font-size: 0.72rem; color: var(--pico-muted-color); cursor: pointer;
  padding: 0; margin: 0; line-height: 1.4; border: 0; width: auto; display: inline-flex; align-items: center; gap: 0.25rem;
}
.tx-toolbar details summary::after { height: 0.8rem; width: 0.8rem; margin-left: 0; }
.tx-toolbar details[open] summary { margin-bottom: 0.15rem; }
.tx-toolbar details summary::-webkit-details-marker { font-size: 0.65em; }
/* Custom category picker (native datalist keyboard + Enter is unreliable) */
.tx-category-picker {
  position: fixed; z-index: 9999; margin: 0; padding: 0.15rem 0;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: 0.25rem;
  box-shadow: 0 0.2rem 0.6rem rgba(0,0,0,0.12);
  max-height: min(40vh, 14rem); overflow-y: auto; font-size: 0.78rem; line-height: 1.2;
}
.tx-category-picker .tx-cat-opt {
  display: block; width: 100%; margin: 0; padding: 0.25rem 0.5rem;
  border: 0; border-radius: 0; text-align: left; font: inherit; cursor: pointer;
  background: transparent; color: inherit;
}
.tx-category-picker .tx-cat-opt:hover { background: var(--kitty-sage-tint); }
.tx-category-picker .tx-cat-opt-active { background: var(--kitty-sage-tint); outline: none; }
.tx-category-picker .tx-cat-opt-create {
  color: var(--kitty-sage-dark); font-style: italic;
  border-top: 1px solid var(--pico-muted-border-color);
}
/* Filter-as-you-type combobox for account <select class="acct-select"> */
.acct-select-hidden { display: none !important; }
.acct-combo-input { margin: 0 !important; width: 100%; }
#bulk-account-select + .acct-combo-input { width: auto; min-width: 14rem; }
.acct-picker {
  position: fixed; z-index: 9999; margin: 0; padding: 0.15rem 0;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: 0.25rem;
  box-shadow: 0 0.2rem 0.6rem rgba(0,0,0,0.12);
  max-height: min(40vh, 16rem); overflow-y: auto; font-size: 0.82rem; line-height: 1.2;
}
.acct-picker .acct-opt {
  display: block; width: 100%; margin: 0; padding: 0.3rem 0.6rem;
  border: 0; border-radius: 0; text-align: left; font: inherit; cursor: pointer;
  background: transparent; color: inherit; white-space: nowrap;
}
.acct-picker .acct-opt:hover { background: var(--kitty-sage-tint); }
.acct-picker .acct-opt-active { background: var(--kitty-sage-tint); outline: none; }
.acct-picker .acct-opt-create {
  color: var(--kitty-sage-dark); font-style: italic;
  border-top: 1px solid var(--pico-muted-border-color);
}
table.tx-compact .tx-cat-inner { display: flex; align-items: center; gap: 0.15rem; min-width: 0; flex-wrap: nowrap; }
/* Multi-account rows: biggest split inline + a "+N" pill that reveals the
   full breakdown via its native title tooltip on hover. */
table.tx-compact .tx-cat-multi {
  display: inline-flex; align-items: center; gap: 0.3rem; min-width: 0;
  font-size: 0.78rem; padding: 0.1rem 0.3rem; cursor: help;
}
table.tx-compact .tx-cat-multi-main {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
table.tx-compact .tx-cat-more {
  flex-shrink: 0; font-size: 0.62rem; font-weight: 700; line-height: 1;
  padding: 0.1rem 0.3rem; border-radius: 0.6rem;
  background: var(--kitty-gold-tint); color: var(--kitty-gold-dark);
}
table.tx-compact .tx-cat-multi:focus { outline: none; }
table.tx-compact .tx-cat-multi:focus .tx-cat-more,
table.tx-compact .tx-cat-multi:hover .tx-cat-more {
  background: var(--kitty-gold); color: #fff;
}
/* Shared, document-level popover for the multi-split breakdown (a table
   scroll container would clip an in-cell absolutely-positioned one). */
.tx-split-pop {
  position: fixed; z-index: 9999; margin: 0; padding: 0.4rem 0.55rem;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: 0.35rem;
  box-shadow: 0 0.2rem 0.7rem rgba(0,0,0,0.16);
  font-size: 0.74rem; line-height: 1.35; max-width: 22rem;
  pointer-events: none;
}
.tx-split-pop .tx-split-pop-row {
  display: flex; justify-content: space-between; gap: 1.25rem; white-space: nowrap;
}
.tx-split-pop .tx-split-pop-row + .tx-split-pop-row { margin-top: 0.15rem; }
.tx-split-pop .tx-split-pop-amt { font-variant-numeric: tabular-nums; color: var(--pico-muted-color); }
table.tx-compact .tx-split-hint { flex-shrink: 0; font-size: 0.65rem; opacity: 0.75; width: 0.85em; text-align: center; line-height: 1; }
table.tx-compact .tx-split-done { color: var(--kitty-sage-dark); }
table.tx-compact .tx-split-partial { color: var(--kitty-gold); }
/* Whole row opens the detail modal (see transactions/list.html) */
table.tk-table tbody tr.tx-row,
table.tk-table tbody tr.exp-row { cursor: pointer; }
.receipt-thumb { max-height: 3rem; border-radius: 0.25rem; }

/* Statement filenames: ellipsis instead of mid-word wrapping (full name
   in the title tooltip). */
td.stmt-stem {
  max-width: 14rem; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* ── Matching suggestions table ──────────────────────────────────────── */
/* Fixed layout so the AI's reasoning column reliably gets the width;
   names/dates/amounts stay compact. The card's .tk-scroll handles narrow
   screens via the min-width. */
table.match-table { table-layout: fixed; min-width: 52rem; }
table.match-table th.match-th-exp { width: 14%; }
table.match-table th.match-th-total { width: 8%; }
table.match-table th.match-th-tx { width: 19%; }
table.match-table th.match-th-paid { width: 9%; }
table.match-table th.match-th-conf { width: 10%; }
table.match-table th.match-th-why { width: 27%; }
table.match-table th.match-th-actions { width: 13%; }
table.match-table td { vertical-align: top; padding-top: 0.55rem; padding-bottom: 0.55rem; overflow-wrap: break-word; }
table.match-table td.match-why small { line-height: 1.45; }

/* ── Expense receipt cards ───────────────────────────────────────────── */
article.receipt-card { padding: 1rem 1.25rem; }
.rc-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin: 0 0 0.6rem; padding: 0; }
.rc-head .rc-date { font-weight: 400; color: var(--pico-muted-color); }
.rc-actions { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; }
.rc-actions button { margin: 0; }
button.rc-parse {
  display: inline-flex; align-items: center; width: auto;
  margin: 0; padding: 0.3rem 0.9rem; font-size: 0.85rem;
}
.rc-spinner {
  display: none; width: 0.85em; height: 0.85em; margin-left: 0.45em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: rc-spin 0.7s linear infinite;
}
button.rc-parse.htmx-request .rc-spinner { display: inline-block; }
@keyframes rc-spin { to { transform: rotate(360deg); } }
.rc-error {
  background: var(--kitty-terracotta-tint); color: var(--kitty-terracotta-dark);
  border-radius: 0.4rem; padding: 0.45rem 0.7rem; font-size: 0.85rem;
}
.rc-ok {
  background: var(--kitty-sage-tint); color: var(--kitty-sage-dark);
  border-radius: 0.4rem; padding: 0.45rem 0.7rem; font-size: 0.85rem;
}
.rc-files { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.85rem; }
.rc-file {
  display: flex; flex-direction: column; gap: 0.25rem; width: 7.5rem;
  border: 1px solid var(--pico-muted-border-color); border-radius: 0.5rem; padding: 0.4rem;
}
.rc-file img { max-width: 100%; max-height: 6.5rem; object-fit: cover; border-radius: 0.3rem; display: block; }
.rc-file .rc-file-doc { font-size: 2.2rem; text-align: center; text-decoration: none; display: block; }
.rc-file small { font-size: 0.62rem; word-break: break-all; color: var(--pico-muted-color); }
.rc-file button { width: 100%; }
.rc-addfiles { margin: 0; align-self: stretch; display: flex; align-items: center; }
.rc-addfiles label { font-size: 0.75rem; color: var(--pico-muted-color); margin: 0; }
.rc-addfiles input[type="file"] { font-size: 0.72rem; margin: 0.2rem 0 0; padding: 0.2rem; height: auto; }
table.rc-items { font-size: 0.85rem; margin-bottom: 0.75rem; }
table.rc-items td, table.rc-items th { padding: 0.25rem 0.5rem; vertical-align: middle; }
table.rc-items select { margin: 0; padding: 0.15rem 1.6rem 0.15rem 0.45rem; font-size: 0.78rem; height: auto; min-height: 0; width: auto; max-width: 18rem; }
table.rc-items input { margin: 0; padding: 0.15rem 0.45rem; font-size: 0.78rem; height: auto; min-width: 8rem; }
table.rc-items input.rc-item-num { min-width: 0; width: 5.5rem; text-align: right; }
.rc-additem .grid label { font-size: 0.85rem; }
#flash { display: none; }
#flash.visible { display: block; }

/* ── Toasts (htmx HX-Trigger → kitty:toast) ──────────────────────────── */
#kitty-toasts {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 11000;
  display: flex; flex-direction: column; gap: 0.5rem; max-width: min(92vw, 24rem);
}
.kitty-toast {
  background: var(--kitty-ink); color: #fff;
  padding: 0.6rem 0.85rem; border-radius: 0.45rem; font-size: 0.85rem;
  box-shadow: 0 0.3rem 0.9rem rgba(0, 0, 0, 0.25);
  opacity: 0; transform: translateY(0.5rem); transition: opacity 0.2s, transform 0.2s;
}
.kitty-toast.show { opacity: 1; transform: translateY(0); }

/* ── Settings section tabs ───────────────────────────────────────────── */
.settings-tabs {
  display: flex; flex-wrap: wrap; gap: 0.25rem; justify-content: flex-start;
  margin: 0 0 1.25rem; border-bottom: 1px solid var(--pico-muted-border-color);
}
.settings-tabs a {
  padding: 0.4rem 0.85rem; text-decoration: none; font-size: 0.9rem; font-weight: 600;
  color: var(--pico-muted-color); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.settings-tabs a:hover { color: var(--pico-color); }
.settings-tabs a.active { color: var(--pico-primary); border-bottom-color: var(--pico-primary); }

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

/* ── Admin: users ────────────────────────────────────────────────────── */
.flash-ok  { color: var(--kitty-sage-dark); }
.flash-err { color: var(--kitty-terracotta-dark); }

.user-add-btn { width: auto; margin: 0; padding: 0.4rem 1rem; }

table.users-table td { vertical-align: middle; }
tr.user-row { cursor: pointer; }
tr.user-row:hover td { background: var(--kitty-cream); }

.user-cell { display: inline-flex; align-items: center; gap: 0.6rem; }
.user-avatar {
  width: 2.1rem; height: 2.1rem; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--kitty-sage-tint); color: var(--kitty-sage-dark);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em;
}
img.user-avatar { object-fit: cover; border: 1px solid var(--pico-muted-border-color); }

/* Avatar picker: a row of selectable chips; the radio itself is visually
   hidden but keeps keyboard/screen-reader behaviour. */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.avatar-picker legend { width: 100%; }
.avatar-opt { position: relative; margin: 0; cursor: pointer; }
.avatar-opt input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; margin: 0; cursor: pointer;
}
.avatar-opt .user-avatar {
  width: 2.3rem; height: 2.3rem;
  border: 2px solid transparent; box-sizing: border-box;
  transition: transform 0.08s ease;
}
.avatar-opt:hover .user-avatar { transform: scale(1.08); }
.avatar-opt input:checked ~ .user-avatar {
  border-color: var(--kitty-sage-dark);
  box-shadow: 0 0 0 2px var(--kitty-sage-tint);
}
.avatar-opt input:focus-visible ~ .user-avatar {
  outline: 2px solid var(--pico-primary); outline-offset: 2px;
}
.user-names { display: inline-flex; flex-direction: column; line-height: 1.25; }
.user-names small { color: var(--pico-muted-color); font-size: 0.78rem; }
.user-you {
  font-weight: 600; color: var(--pico-muted-color);
  border: 1px solid var(--pico-muted-border-color); border-radius: 0.6em;
  padding: 0 0.45em; font-size: 0.68rem; vertical-align: 0.1em;
}
.user-email { color: var(--pico-muted-color); font-size: 0.88rem; }
.user-none { color: var(--pico-muted-color); }
.user-when { color: var(--pico-muted-color); font-size: 0.85rem; white-space: nowrap; }

.badge.role-admin    { background: var(--kitty-terracotta-tint); color: var(--kitty-terracotta-dark); }
.badge.role-member   { background: var(--kitty-sage-tint); color: var(--kitty-sage-dark); }
.badge.role-readonly { background: var(--pico-card-sectioning-background-color, #f3efe4); color: var(--pico-muted-color); border: 1px solid var(--pico-muted-border-color); }

.user-status { font-size: 0.85rem; white-space: nowrap; }
.user-status::before {
  content: ""; display: inline-block; width: 0.5em; height: 0.5em;
  border-radius: 50%; margin-right: 0.35em; vertical-align: 0.08em;
}
.user-status-active::before  { background: var(--kitty-sage); }
.user-status-invited::before { background: var(--kitty-gold); }
.user-status-expired::before { background: var(--kitty-terracotta); }
.user-status-invited { color: var(--kitty-gold-dark); }
.user-status-expired { color: var(--kitty-terracotta-dark); }

dialog#user-modal > article.tx-modal-card,
dialog#user-new-modal > article.tx-modal-card { max-width: 34rem; width: min(94vw, 34rem); }

/* User modal: larger identity header, denser form */
#user-modal .tx-modal-head .user-avatar { width: 2.8rem; height: 2.8rem; font-size: 1rem; }
#user-modal .tx-modal-head .user-names strong { font-size: 1.05rem; font-weight: 650; }
#user-modal .tx-modal-head .user-names small { font-size: 0.8rem; }
.user-modal-meta { color: var(--pico-muted-color); font-size: 0.8rem; margin: -0.35rem 0 1.1rem; }
#user-modal label, #user-new-modal label { font-size: 0.85rem; }
#user-modal input:not([type="radio"]):not([type="checkbox"]),
#user-new-modal input:not([type="radio"]):not([type="checkbox"]) {
  padding: 0.45rem 0.7rem; height: auto; font-size: 0.92rem; margin-bottom: 0.9rem;
}
#user-modal fieldset, #user-new-modal fieldset { margin-bottom: 1rem; }
.user-modal-h {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--pico-muted-color); margin: 0 0 0.6rem;
}
.user-manual-pw { margin-top: 0.9rem; }
.user-manual-pw summary { font-size: 0.85rem; color: var(--pico-muted-color); }
.user-manual-pw summary:hover { color: var(--kitty-ink); }
.user-manual-pw form { margin-top: 0.75rem; }
.user-delete-btn { color: var(--kitty-terracotta-dark); border-color: var(--kitty-terracotta-dark); }
.user-delete-btn:hover { color: #fff; background: var(--kitty-terracotta-dark); border-color: var(--kitty-terracotta-dark); }
.page-head h2 { margin: 0; }
.page-head [role="button"] { margin: 0; padding: 0.3rem 0.85rem; font-size: 0.8rem; }

/* ── Table kit: generic sortable/filterable table chrome ─────────────── */
/* Toolbar row: quick filter + actions */
.tk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }
.tk-quick { flex: 1 1 16rem; max-width: 24rem; margin: 0; }
.tk-quick input[type="search"] { margin: 0; padding: 0.35rem 0.75rem 0.35rem 2.1rem; font-size: 0.85rem; height: auto; }
button.tk-clear-all {
  margin: 0; padding: 0.32rem 0.7rem; font-size: 0.75rem; width: auto;
  background: none; border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color); border-radius: var(--pico-border-radius); cursor: pointer;
}
button.tk-clear-all:hover { color: var(--pico-color); border-color: var(--pico-secondary); box-shadow: none; }
.tk-toolbar form { margin: 0; }
.tk-toolbar .tx-bulk-bar { margin-left: auto; display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }
.tk-toolbar .tx-bulk-bar button { margin: 0; padding: 0.3rem 0.7rem; font-size: 0.75rem; width: auto; }

/* Card wrapper around the table */
.tk-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.5rem; overflow: hidden; margin-bottom: 1rem;
  background: var(--pico-card-background-color, #fff);
}
.tk-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.4rem 0.75rem; font-size: 0.72rem; color: var(--pico-muted-color);
  background: var(--pico-form-element-background-color, #fbfcfd);
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.tk-scroll { overflow-x: auto; }
table.tk-table { margin: 0; }
table.tk-table thead th {
  background: var(--pico-form-element-background-color, #fbfcfd);
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-top: 0.32rem; padding-bottom: 0.32rem;
  vertical-align: middle;
}
table.tk-table tbody tr:hover td { background: rgba(111, 138, 85, 0.07); }
table.tk-table tbody tr.tk-empty td { padding: 1.5rem; text-align: center; color: var(--pico-muted-color); font-size: 0.85rem; }

/* Header cell: label / sort button / filter toggle */
.tk-th { display: inline-flex; align-items: center; gap: 0.12rem; max-width: 100%; }
.tk-th-right { width: 100%; justify-content: flex-end; }
.tk-label { padding: 0.1rem 0.15rem; }
button.tk-sort {
  background: none; border: 0; margin: 0; padding: 0.1rem 0.15rem; width: auto;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit;
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.22rem; border-radius: 0.25rem;
  box-shadow: none;
}
button.tk-sort:hover, button.tk-sort:focus-visible { color: var(--pico-primary); background: none; box-shadow: none; }
.tk-arrow { font-size: 0.55rem; line-height: 1; opacity: 0.25; }
button.tk-sort.tk-active { color: var(--pico-primary); }
button.tk-sort.tk-active .tk-arrow { opacity: 1; }

/* Reveal-on-hover header affordances. The "⋯" column menu and the inactive
   sort arrow always keep their width (visibility, not display) so columns
   never resize on hover — they are merely invisible until the column is
   hovered, keyboard focused, open, or carrying active state (a live filter
   or grouping). */
.tk-table thead th details.tk-menu { visibility: hidden; }
.tk-table thead th:hover details.tk-menu,
.tk-table thead th:focus-within details.tk-menu,
.tk-table thead th details.tk-menu[open],
.tk-table thead th details.tk-menu.tk-on,
.tk-table thead th details.tk-menu.tk-grouped { visibility: visible; }
.tk-table thead th button.tk-sort:not(.tk-active) .tk-arrow { visibility: hidden; }
.tk-table thead th:hover button.tk-sort .tk-arrow,
.tk-table thead th:focus-within button.tk-sort .tk-arrow { visibility: visible; }

/* Column menus (sort direction / group by / filters behind one "⋯") */
details.tk-menu { position: relative; margin: 0; display: inline-flex; }
details.tk-menu > summary {
  list-style: none; cursor: pointer; margin: 0; padding: 0.15rem; line-height: 0;
  border-radius: 0.25rem; color: var(--pico-muted-color); position: relative; display: inline-flex;
  /* WCAG AA target size: keep the hit area at least 24x24px. */
  min-width: 24px; min-height: 24px; align-items: center; justify-content: center;
}
details.tk-menu > summary::-webkit-details-marker { display: none; }
details.tk-menu > summary::marker { content: ""; }
/* Pico draws an accordion chevron via summary::after — suppress it here */
details.tk-menu > summary::after { display: none; background: none; margin: 0; float: none; }
details.tk-menu > summary:hover, details.tk-menu[open] > summary { color: var(--pico-primary); }
details.tk-menu.tk-on > summary, details.tk-menu.tk-grouped > summary { color: var(--pico-primary); }
details.tk-menu.tk-on > summary::after, details.tk-menu.tk-grouped > summary::after {
  content: ""; display: block; position: absolute; top: -0.05rem; right: -0.1rem;
  width: 0.38rem; height: 0.38rem; border-radius: 50%; background: var(--pico-primary);
}
.tk-dots { width: 0.9rem; height: 0.9rem; display: block; }
.tk-menu-pop { min-width: 12rem; padding: 0.4rem; }
button.tk-menu-item {
  display: flex; align-items: center; gap: 0.45rem; width: 100%;
  margin: 0; padding: 0.32rem 0.45rem; font-size: 0.78rem; font-weight: 400;
  text-transform: none; letter-spacing: normal; text-align: left;
  /* Pico resolves --pico-color to white inside buttons — use the ink colour */
  background: none; border: 0; border-radius: 0.3rem; color: var(--kitty-ink);
  cursor: pointer; box-shadow: none; white-space: nowrap;
}
button.tk-menu-item:hover, button.tk-menu-item:focus-visible {
  background: var(--pico-form-element-background-color, rgba(0, 0, 0, 0.04));
  color: var(--kitty-ink); box-shadow: none;
}
button.tk-menu-item.tk-active, button.tk-menu-item.tk-on { color: var(--pico-primary); font-weight: 600; }
.tk-menu-glyph { width: 1rem; text-align: center; flex-shrink: 0; opacity: 0.7; font-size: 0.8rem; }
hr.tk-menu-sep { margin: 0.3rem 0.1rem; border: 0; border-top: 1px solid var(--pico-muted-border-color); }
.tk-menu-filter { padding: 0.15rem 0.45rem 0.1rem; }
.tk-pop {
  position: absolute; top: calc(100% + 0.35rem); left: 0; z-index: 100;
  min-width: 13rem; padding: 0.65rem 0.65rem 0.55rem; cursor: auto;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 0.4rem; box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.16);
  font-size: 0.75rem; font-weight: 400; text-transform: none; letter-spacing: normal;
  color: var(--pico-color); text-align: left;
}
.tk-pop-right { left: auto; right: 0; }
.tk-pop-title { display: block; margin: 0 0 0.4rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--pico-muted-color); }
.tk-pop label.tk-check {
  display: flex; align-items: center; gap: 0.45rem; margin: 0 0 0.05rem; padding: 0.22rem 0.3rem;
  font-size: 0.78rem; font-weight: 400; text-transform: none; letter-spacing: normal;
  color: var(--pico-color); cursor: pointer; border-radius: 0.3rem; white-space: nowrap;
}
.tk-pop label.tk-check:hover { background: var(--pico-form-element-background-color, rgba(0, 0, 0, 0.04)); }
.tk-pop label.tk-check input[type="checkbox"] {
  margin: 0; width: 0.92rem; height: 0.92rem; min-height: 0; flex-shrink: 0;
}
.tk-pop label { display: block; margin: 0 0 0.45rem; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--pico-muted-color); }
.tk-pop input, .tk-pop select {
  display: block; width: 100%; margin: 0.18rem 0 0; padding: 0.25rem 0.45rem;
  font-size: 0.78rem; font-weight: 400; height: auto; min-height: 0;
  text-transform: none; letter-spacing: normal; color: var(--pico-color);
}
button.tk-pop-clear {
  margin: 0.15rem 0 0; padding: 0.18rem 0.55rem; font-size: 0.7rem; width: auto;
  background: none; border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color); border-radius: 0.3rem; cursor: pointer; box-shadow: none;
}
button.tk-pop-clear:hover { color: var(--pico-color); border-color: var(--pico-secondary); box-shadow: none; }

/* ── Group panel (data-grid grouping) ────────────────────────────────── */
.tk-groupbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem;
  margin: 0 0 0.5rem; padding: 0.4rem 0.6rem; min-height: 2.2rem;
  border: 1px dashed var(--pico-muted-border-color);
  border-radius: 0.45rem; background: var(--pico-form-element-background-color, #fbfcfd);
}
.tk-groupbar.tk-dragover { border-color: var(--pico-primary); background: var(--kitty-sage-tint); }
.tk-groupbar-label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--pico-muted-color);
}
.tk-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.tk-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.12rem 0.2rem 0.12rem 0.4rem; font-size: 0.76rem;
  background: var(--kitty-sage-tint); color: var(--kitty-sage-dark);
  border: 1px solid var(--pico-muted-border-color); border-radius: 0.8rem; cursor: grab;
}
.tk-chip.sortable-ghost { opacity: 0.4; }
.tk-chip-grip { font-size: 0.6rem; opacity: 0.55; letter-spacing: -0.2em; user-select: none; }
.tk-chip-label { font-weight: 600; }
button.tk-chip-x {
  width: auto; margin: 0; padding: 0 0.25rem; font-size: 0.85rem; line-height: 1;
  background: none; border: 0; color: inherit; cursor: pointer; box-shadow: none; opacity: 0.7;
}
button.tk-chip-x:hover { opacity: 1; color: var(--kitty-terracotta); background: none; box-shadow: none; }
.tk-groupbar-hint { font-size: 0.74rem; color: var(--pico-muted-color); }
.tk-group-actions { margin-left: auto; display: inline-flex; gap: 0.3rem; }
button.tk-group-toggle-all {
  width: auto; margin: 0; padding: 0.15rem 0.55rem; font-size: 0.7rem;
  background: none; border: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color); border-radius: 0.3rem; cursor: pointer; box-shadow: none;
}
button.tk-group-toggle-all:hover { color: var(--pico-color); border-color: var(--pico-secondary); box-shadow: none; }
/* Group-header rows inside the grid */
table.tk-table tr.tk-group td {
  background: var(--kitty-sage-tint);
  border-top: 1px solid var(--pico-muted-border-color);
  font-size: 0.74rem; padding-top: 0.22rem; padding-bottom: 0.22rem;
}
table.tk-table tr.tk-group:hover td { background: var(--kitty-sage-tint); }
.tk-group-label { cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--kitty-sage-dark); }
.tk-group-caret { display: inline-block; width: 0.8em; font-size: 0.7rem; transition: transform 0.1s; }
tr.tk-group.tk-collapsed .tk-group-caret { transform: rotate(-90deg); }
.tk-group-name { margin: 0 0.4rem; }
.tk-group-count {
  font-weight: 500; font-size: 0.66rem; color: var(--pico-muted-color);
  background: var(--pico-card-background-color, #fff); border-radius: 0.7rem; padding: 0.02rem 0.4rem;
}
.tk-group-cell { font-variant-numeric: tabular-nums; }
.tk-group-right { text-align: right; }
tr.tk-hidden { display: none; }

/* ── App modals (transaction detail, create expense, users, …) ───────── */
/* The dialog (or its card) takes focus on showModal() — never ring it;
   focus rings belong on the controls inside. */
dialog:focus, dialog:focus-visible,
.tx-modal-card:focus, .tx-modal-card:focus-visible { outline: none; }
dialog.app-modal::backdrop,
dialog#tx-modal::backdrop {
  background: rgba(43, 36, 28, 0.45);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
dialog.app-modal > article.tx-modal-card,
dialog#tx-modal > article.tx-modal-card {
  max-width: 64rem; width: min(94vw, 64rem);
  max-height: 88vh; overflow-y: auto;
  padding: 1.1rem 1.4rem 1.4rem;
  border: 1px solid rgba(67, 57, 46, 0.08);
  border-radius: 0.85rem;
  box-shadow: 0 1.4rem 3.2rem rgba(43, 36, 28, 0.25), 0 0.2rem 0.6rem rgba(43, 36, 28, 0.1);
}
@media (prefers-reduced-motion: no-preference) {
  dialog.app-modal[open] > article.tx-modal-card,
  dialog#tx-modal[open] > article.tx-modal-card { animation: kitty-modal-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1); }
  dialog.app-modal[open]::backdrop,
  dialog#tx-modal[open]::backdrop { animation: kitty-fade-in 0.18s ease-out; }
}
@keyframes kitty-modal-in { from { opacity: 0; transform: translateY(0.6rem) scale(0.98); } }
@keyframes kitty-fade-in { from { opacity: 0; } }
dialog#exp-create-modal > article.tx-modal-card { max-width: 42rem; width: min(94vw, 42rem); }
dialog#exp-modal > article.tx-modal-card { max-width: 64rem; width: min(94vw, 64rem); }
.tx-modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  /* Undo Pico's article>header sectioning band */
  background: none; border-radius: 0;
  margin: 0 0 1rem; padding: 0 0 0.8rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.tx-modal-head strong { font-size: 1rem; line-height: 1.3; }
.tx-modal-actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
.tx-modal-actions a, .tx-modal-actions button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; margin: 0; padding: 0;
  font-size: 0.95rem; line-height: 1; text-decoration: none;
  background: none; border: 0;
  border-radius: 50%; color: var(--pico-muted-color); cursor: pointer; box-shadow: none;
}
.tx-modal-actions a:hover, .tx-modal-actions button:hover,
.tx-modal-actions a:focus-visible, .tx-modal-actions button:focus-visible {
  color: var(--kitty-ink); background: rgba(67, 57, 46, 0.08); border: 0; box-shadow: none;
}
.tx-modal-card hr { margin: 1.3rem 0 1rem; border: 0; border-top: 1px solid var(--pico-muted-border-color); }
.tx-modal-card fieldset > legend {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--pico-muted-color); margin: 0 0 0.5rem;
}
.tx-modal-card .tx-detail-grid article { margin: 0; box-shadow: none; border: 1px solid var(--pico-muted-border-color); }

/* Stacked radio option with a title + muted description (role/access pickers) */
label.opt-row { display: flex; align-items: flex-start; gap: 0.55rem; margin: 0 0 0.45rem; cursor: pointer; }
label.opt-row input[type="radio"] { margin: 0.12rem 0 0; flex-shrink: 0; }
.opt-text { display: flex; flex-direction: column; line-height: 1.3; }
.opt-text strong { font-size: 0.88rem; font-weight: 600; color: var(--kitty-ink); }
.opt-text small { font-size: 0.78rem; color: var(--pico-muted-color); }

/* Right-aligned modal action row */
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }
.modal-foot button { width: auto; margin: 0; padding: 0.45rem 1.1rem; font-size: 0.85rem; }

/* Compact secondary action (send invite / reset link / set password) */
button.user-action-btn {
  width: auto; margin: 0; padding: 0.4rem 0.85rem; font-size: 0.82rem;
  display: inline-flex; align-items: center; gap: 0.4rem;
}

/* Danger zone panel */
.danger-panel {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 0.9rem; margin: 0;
  border: 1px solid #e2c0b0; background: var(--kitty-terracotta-tint); border-radius: 0.6rem;
}
.danger-panel p { margin: 0; font-size: 0.8rem; color: var(--kitty-terracotta-dark); line-height: 1.35; }
.danger-panel p strong { display: block; font-size: 0.85rem; }
.danger-panel form { margin: 0; }

/* ── Image lightbox ──────────────────────────────────────────────────── */
.rc-file a.rc-file-img { cursor: zoom-in; display: block; }
#kitty-lightbox {
  position: fixed; inset: 0; z-index: 12000;
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  margin: 0; padding: 2.5rem 1rem; border: 0; background: transparent;
  overflow: hidden;
}
#kitty-lightbox[open] { display: flex; align-items: center; justify-content: center; }
#kitty-lightbox::backdrop { background: rgba(35, 30, 24, 0.85); }
#kitty-lightbox img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 0.4rem; box-shadow: 0 0.6rem 1.8rem rgba(0, 0, 0, 0.45);
  background: var(--kitty-card);
}
#kitty-lightbox .klb-btn {
  position: absolute; display: inline-flex; align-items: center; justify-content: center;
  width: 2.6rem; height: 2.6rem; margin: 0; padding: 0;
  font-size: 1.4rem; line-height: 1; cursor: pointer;
  color: #fff; background: rgba(0, 0, 0, 0.35); border: 0; border-radius: 50%;
  box-shadow: none;
}
#kitty-lightbox .klb-btn:hover { background: rgba(0, 0, 0, 0.6); }
#kitty-lightbox .klb-close { top: 1rem; right: 1rem; }
#kitty-lightbox .klb-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
#kitty-lightbox .klb-next { right: 1rem; top: 50%; transform: translateY(-50%); }
#kitty-lightbox .klb-caption {
  position: absolute; bottom: 0.85rem; left: 50%; transform: translateX(-50%);
  max-width: 80%; padding: 0.3rem 0.85rem; border-radius: 0.6rem;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 0.8rem; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#kitty-lightbox.single .klb-prev,
#kitty-lightbox.single .klb-next { display: none; }
