.categories-view{max-width:1100px}
.categories-toolbar{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto auto;
  gap:10px;
  align-items:end;
  padding:13px;
  margin-bottom:12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--card);
}
.categories-toolbar label{margin:0;font-size:12px}
.categories-toolbar input,
.categories-toolbar select,
.categories-toolbar button{min-height:42px}
.categories-toolbar button{padding:0 14px;white-space:nowrap}
.categories-note{
  margin:0 0 14px;
  color:var(--muted);
  font-size:13px;
}
.category-section{margin:0 0 16px}
.category-section>h2{
  margin:16px 0 8px;
  font:800 13px Manrope;
  letter-spacing:.08em;
  color:var(--muted);
}
/* One card per group; rows inside it are split by hairlines, not separate cards. */
.category-group{
  margin:0 0 8px;
  /* --line alone is ~1.2:1 on the page; this mix reads as an edge (~3.2:1). */
  border:1px solid color-mix(in srgb,var(--line) 55%,var(--ink));
  border-radius:12px;
  background:var(--card);
  overflow:hidden;
}
.category-group-heading{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  min-height:40px;
  padding:4px 12px;
  margin:0;
  border:0;
  border-bottom:1px solid color-mix(in srgb,var(--line) 75%,var(--ink));
  background:transparent;
  cursor:default;
  pointer-events:none;
}
.category-group-heading .category-actions{pointer-events:auto}
.category-group-title{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;min-width:0}
.category-group-heading h3{
  margin:0;
  font:800 12px Manrope;
  letter-spacing:.06em;
  text-transform:uppercase;
  color:var(--muted);
  overflow-wrap:anywhere;
}
.category-group-leaves{padding:0}
.category-leaf-row{
  display:grid;
  grid-template-columns:20px minmax(0,1fr) auto;
  align-items:center;
  gap:8px;
  width:100%;
  min-height:40px;
  padding:4px 12px;
  margin:0;
  border:0;
  border-radius:0;
  background:transparent;
  color:var(--ink);
  text-align:left;
}
.category-leaf-row+.category-leaf-row{border-top:1px solid color-mix(in srgb,var(--line) 75%,var(--ink))}
.category-leaf-row:hover{background:rgba(23,35,31,.06)}
.category-leaf-name{min-width:0;overflow-wrap:anywhere}
.category-leaf-row strong{margin:0;font:600 14px 'DM Sans',sans-serif}
.category-leaf-row.is-archived strong{color:#3d4a46}
.category-leaf-row.category-leaf-empty{display:block;color:var(--muted);font-size:13px}
.category-leaf-row.category-leaf-empty:hover{background:transparent}
/* A group holding one category of the same name ("Housing" > "Housing") shows a
   single line; the heading stays for screen readers only. */
.category-group.is-collapsed .category-group-heading{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0,0,0,0);white-space:nowrap;border:0;
}
.category-meta{
  display:inline-flex;
  flex-wrap:wrap;
  gap:4px;
  margin-left:4px;
  vertical-align:middle;
}
.category-chip{
  display:inline-flex;
  align-items:center;
  height:20px;
  padding:0 8px;
  border-radius:999px;
  background:color-mix(in srgb,var(--green) 12%,transparent);
  color:var(--ink);
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
}
.category-chip.archived{background:transparent;border:1px dashed var(--line);color:#3d4a46}
.category-actions{display:flex;flex-wrap:nowrap;gap:4px;justify-self:end}
.category-actions button{
  height:32px;
  padding:0 12px;
  border:1px solid var(--line);
  border-radius:8px;
  background:transparent;
  color:var(--ink);
  font-size:13px;
  font-weight:600;
  cursor:pointer;
}
.category-actions button:focus-visible{outline:2px solid var(--green);outline-offset:-2px}
.category-actions-secondary button{
  height:28px;
  padding:0 8px;
  border-color:transparent;
  color:var(--muted);
  font-size:12px;
  font-weight:600;
}
.category-dot-swatch{
  justify-self:center;
  width:12px;
  height:12px;
  border-radius:50%;
}
.category-icon{justify-self:center;font-size:14px;line-height:1}
.category-group-title .category-icon{font-size:13px}
.categories-empty{
  padding:28px 16px;
  border:1px dashed var(--line);
  border-radius:12px;
  color:var(--muted);
  text-align:center;
}
.category-editor-dialog{
  width:min(520px,calc(100vw - 24px));
  border:1px solid var(--line);
  border-radius:18px;
  background:var(--card);
  color:var(--ink);
  padding:0;
}
.category-editor-dialog::backdrop{background:rgba(8,16,14,.55)}
.category-editor-dialog form{
  display:grid;
  gap:12px;
  padding:18px;
}
.category-editor-dialog h2{margin:0;font:800 20px Manrope}
.category-editor-help{
  margin:0;
  color:var(--muted);
  font-size:13px;
}
.category-editor-dialog label{margin:0;font-size:12px}
.category-editor-dialog input,
.category-editor-dialog select{min-height:42px}
.category-editor-dialog .dialog-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:4px;
}
@media(max-width:720px){
  .categories-toolbar{grid-template-columns:1fr}
  .category-leaf-row{padding-top:6px;padding-bottom:6px}
}
@media(pointer:coarse){
  .category-leaf-row{min-height:48px}
  .category-actions button{height:auto;min-height:44px;min-width:44px}
}
body[data-theme="midnight"] .category-leaf-row:hover{background:rgba(243,245,255,.06)}
body[data-theme="midnight"] .category-group{border-color:#5a6699}
body[data-theme="midnight"] .category-leaf-row+.category-leaf-row,
body[data-theme="midnight"] .category-group-heading{border-color:#2c3358}
body[data-theme="midnight"] .category-leaf-row.is-archived strong,
body[data-theme="midnight"] .category-chip.archived{color:#c5cce6}
body[data-theme="midnight"] .category-actions button:focus-visible{outline-color:#8fb0ff}

/* Archive confirm: same look as the discard-changes confirm, but its own class so
   the dirty-form guard never counts it as a second "discard changes" prompt. */
.category-archive-dialog::backdrop{background:rgba(14,30,24,.26)}
.category-archive-dialog{
  width:min(400px,calc(100% - 24px));
  padding:24px;
  background:var(--card);
  color:var(--ink);
}
.category-archive-dialog h2{margin:0 0 8px;font:800 20px Manrope,system-ui,sans-serif;overflow-wrap:anywhere}
.category-archive-dialog p{margin:0 0 12px;color:var(--muted);line-height:1.5}
.category-archive-dialog .dialog-actions{display:flex;gap:8px;margin-top:6px}
.category-archive-dialog .dialog-actions button{
  flex:1 1 50%;
  width:auto;
  min-height:44px;
  border-radius:9px;
  font-weight:800;
  cursor:pointer;
}
.category-archive-dialog .dialog-actions button:focus-visible{outline:3px solid var(--green);outline-offset:2px}
