/* Help Admin (Phase H3). Everything is prefixed ha-. Uses the app's theme tokens, so it
   follows light and dark automatically. Touch targets are >= 44px at phone width. */
.ha-page, .ha-editor { max-width: 1280px; }
[class^="ha-"] [hidden], .ha-addpanel[hidden], .ha-menu[hidden] { display: none !important; }
.ha-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.ha-intro { margin: 0 0 16px; max-width: 70ch; }
.ha-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.ha-field-error { color: var(--danger); font-size: 12.5px; margin-top: 4px; min-height: 0; }
.ha-field-error:empty { display: none; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.ha-counter { font-size: 11.5px; color: var(--text-faint); font-family: var(--font-mono); }
.ha-counter--block { text-align: right; margin-top: 2px; }
.ha-counter.is-over { color: var(--danger); font-weight: 600; }
/* Solid confirm button: a fixed deep red so white text passes AA (4.5:1) in both themes - the theme --danger
   token is a light tint in dark mode and only ~4.3:1 in light mode. Hover darkens instead of lightening. */
.ha-btn-danger { background: #C8274A; border-color: #C8274A; color: #fff; }
.ha-btn-danger:hover { background: #C8274A; filter: brightness(.9); border-color: #C8274A; }
/* The light theme forces a white background on every non-primary .btn via
   `html.theme-light .btn:not(.btn-primary)` (specificity 0,3,1), which turned the
   destructive confirm into white-on-white. Match that specificity and win by order. */
html.theme-light .btn.ha-btn-danger, html.theme-light .btn.ha-btn-danger:hover { background: #C8274A; border-color: #C8274A; color: #fff; }
.ha-btn-danger-outline { color: var(--danger); border-color: var(--danger-soft); }
.ha-btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }

/* sub navigation */
.ha-subnav { display: flex; gap: 4px; margin: -8px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.ha-subnav__link { padding: 10px 14px; color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.ha-subnav__link:hover { color: var(--text); }
.ha-subnav__link.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* status pills */
.ha-pill { font-weight: 600; }
.ha-pill--draft { color: var(--info); background: var(--info-soft); }
.ha-pill--published { color: var(--ok); background: var(--ok-soft); }
.ha-pill--needs_review { color: var(--warn); background: var(--warn-soft); }
.ha-pill--archived, .ha-pill--superseded { color: var(--text-muted); background: var(--line-soft); }
.ha-pill--unpublished { color: var(--purple); background: var(--purple-soft); }

/* icon buttons */
.ha-iconbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent; color: var(--text-muted); cursor: pointer; }
.ha-iconbtn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.ha-iconbtn:disabled { opacity: 0.35; cursor: not-allowed; }
.ha-iconbtn:focus-visible, .ha-tab:focus-visible, .ha-addtype:focus-visible, .ha-menu__item:focus-visible, .ha-iconpick:focus-visible, .ha-picker__item:focus-visible, .ha-related__add:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ha-handle { cursor: grab; touch-action: none; }
.ha-handle:active { cursor: grabbing; }
.ha-danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); }
.ha-row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.is-dragging { opacity: 0.45; }

/* dialogs */
.ha-overlay { z-index: 300; padding: 16px; }
.ha-dialog { width: min(480px, 100%); max-height: 92vh; overflow-y: auto; }
.ha-dialog__msg { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.ha-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.ha-problems { margin: 0 0 8px 18px; font-size: 13.5px; }
.ha-picker { width: min(640px, 100%); }
.ha-picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.ha-picker__item { display: flex; flex-direction: column; gap: 6px; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; text-align: left; color: var(--text); min-height: 44px; }
.ha-picker__item:hover { border-color: var(--accent); }
.ha-picker__item .ha-thumb { width: 100%; height: 80px; object-fit: cover; }
.ha-picker__alt { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* popup menu */
.ha-menu { position: fixed; z-index: 400; min-width: 200px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.28); padding: 4px; display: flex; flex-direction: column; }
.ha-menu__item { text-align: left; background: none; border: 0; color: var(--text); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; cursor: pointer; min-height: 40px; }
.ha-menu__item:hover:not(:disabled) { background: var(--surface-hover); }
.ha-menu__item.is-danger { color: var(--danger); }

/* list page */
.ha-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.ha-tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.ha-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-muted); padding: 9px 12px; font-size: 13.5px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; min-height: 44px; }
.ha-tab:hover { color: var(--text); }
.ha-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }
.ha-tab__n { font-family: var(--font-mono); font-size: 11.5px; background: var(--line-soft); border-radius: 999px; padding: 1px 7px; color: var(--text-muted); }
.ha-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.ha-search { flex: 1 1 240px; min-width: 0; }
.ha-select { flex: 0 1 220px; min-width: 0; }
.ha-group { margin-bottom: 22px; }
.ha-group__title { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; font-weight: 500; }
.ha-group__n { background: var(--line-soft); border-radius: 999px; padding: 1px 7px; }
.ha-rows { display: flex; flex-direction: column; gap: 6px; }
.ha-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.ha-row:hover { border-color: var(--text-faint); }
.ha-row__main { min-width: 0; }
.ha-row__title { color: var(--text); font-weight: 600; font-size: 14.5px; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ha-row__title:hover { color: var(--accent); }
.ha-row__meta { font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ha-row__flags { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.ha-flag { display: inline-flex; }
.ha-flag--star { color: var(--warn); }
.ha-flag--note { color: var(--accent); }
.ha-row__actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.ha-empty { text-align: center; padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.ha-empty__title { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.ha-empty .ha-row-actions { justify-content: center; margin-top: 14px; }
.ha-skel-row { height: 52px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line-soft), var(--surface-hover), var(--line-soft)); background-size: 200% 100%; animation: ha-shimmer 1.2s infinite; margin-bottom: 8px; }
@keyframes ha-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ha-skel-row { animation: none; } }
.ha-error { border: 1px solid var(--danger); background: var(--danger-soft); border-radius: var(--radius); padding: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }

/* editor */
.ha-topbar { position: sticky; top: -24px; z-index: 30; margin: -24px -28px 16px; padding: 10px 28px; background: var(--bg); border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ha-topbar__left { display: flex; gap: 10px; align-items: center; min-width: 0; flex-wrap: wrap; flex: 1 1 320px; }
.ha-back { color: var(--text-muted); text-decoration: none; font-size: 13.5px; padding: 8px 4px; min-height: 36px; display: inline-flex; align-items: center; }
.ha-back:hover { color: var(--text); }
.ha-topbar__title { font-weight: 600; font-size: 15px; max-width: 34ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ha-topbar__status { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ha-version { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.ha-unsaved { font-size: 12.5px; color: var(--warn); font-weight: 600; }
.ha-unsaved:empty { display: none; }
.ha-topbar__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ha-morebtn { padding: 9px 12px; }
.ha-banners:empty { display: none; }
.ha-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.45; }
.ha-banner--warn { background: var(--warn-soft); border: 1px solid var(--warn); }
.ha-banner--error { background: var(--danger-soft); border: 1px solid var(--danger); }
.ha-banner__text { flex: 1 1 320px; }
.ha-editor__grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
.ha-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ha-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ha-section > summary { cursor: pointer; padding: 12px 14px; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; justify-content: space-between; min-height: 44px; align-items: center; }
.ha-section > summary::-webkit-details-marker { display: none; }
.ha-section > summary::after { content: '+'; color: var(--text-muted); font-size: 18px; }
.ha-section[open] > summary::after { content: '–'; }
.ha-section__body { padding: 2px 14px 14px; }
.ha-publink { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--accent); margin: 4px 0 12px; text-decoration: none; }
.ha-main { min-width: 0; }
.ha-main__title { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 500; margin: 0 0 10px; }
.ha-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; }
.ha-chips__list { display: contents; }
.ha-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; }
.ha-chip__x { background: none; border: 0; color: var(--text-muted); cursor: pointer; font-size: 16px; min-width: 24px; min-height: 24px; border-radius: 50%; line-height: 1; }
.ha-chip__x:hover { color: var(--danger); }
.ha-chips__input { flex: 1 1 120px; min-width: 100px; border: 0 !important; background: transparent !important; padding: 6px !important; }
.ha-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.ha-check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; min-height: 36px; cursor: pointer; }
.ha-check input { width: 18px; height: 18px; flex: none; }
.ha-check--wide { margin-top: 6px; }
.ha-related__list, .ha-related__results { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ha-related__item { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--surface-hover); border-radius: var(--radius-sm); padding: 2px 4px 2px 10px; font-size: 13.5px; }
.ha-related__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ha-related__add { width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text); cursor: pointer; font-size: 13.5px; min-height: 40px; }
.ha-related__add:hover { border-color: var(--accent); }
.ha-related__cat { color: var(--text-muted); font-size: 12px; }

/* blocks */
.ha-blocks__empty { text-align: center; padding: 28px 14px; border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.ha-blocks__empty-title { font-weight: 600; margin-bottom: 4px; }
.ha-blocks__list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.ha-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 12px; }
.ha-block.has-error { border-color: var(--danger); }
.ha-block__head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.ha-block__type { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); flex: 1; min-width: 0; }
.ha-block__tools { display: flex; gap: 2px; }
.ha-block__errors { color: var(--danger); font-size: 13px; }
.ha-block__errors:empty { display: none; }
.ha-block__errors div { margin-top: 6px; }
.ha-bfield { margin-bottom: 10px; }
.ha-bfield textarea, .ha-bfield input { width: 100%; }
.ha-addwrap { position: relative; }
.ha-addbtn { min-height: 44px; }
.ha-addpanel { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin-top: 10px; }
.ha-addtype { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text); cursor: pointer; min-height: 44px; }
.ha-addtype:hover { border-color: var(--accent); }
.ha-addtype__label { font-weight: 600; font-size: 14px; }
.ha-addtype__hint { font-size: 12px; color: var(--text-muted); }
.ha-steps { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: ha-step; }
.ha-step { display: flex; gap: 8px; align-items: flex-start; counter-increment: ha-step; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 8px; }
.ha-step::before { content: counter(ha-step); font-family: var(--font-mono); background: var(--accent-soft); color: var(--accent); border-radius: 50%; min-width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; margin-top: 6px; }
.ha-step__main { flex: 1; min-width: 0; }
.ha-step__main textarea { width: 100%; }
.ha-step__tools { display: flex; flex-direction: column; }
.ha-step__img { margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.ha-step__imgfields { display: flex; flex-direction: column; gap: 6px; flex: 1 1 200px; min-width: 0; }
.ha-thumb { width: 72px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-hover); flex: none; }
.ha-thumb--lg { width: 160px; height: 110px; }
.ha-imgblock { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }

/* media */
.ha-dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.ha-dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.ha-dropzone__text { font-weight: 600; font-size: 13.5px; }
.ha-media__status { font-size: 12.5px; color: var(--text-muted); min-height: 18px; margin: 6px 0; }
.ha-media__list { display: flex; flex-direction: column; gap: 8px; }
.ha-mitem { display: grid; grid-template-columns: 32px 72px minmax(0, 1fr); gap: 8px; align-items: start; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 8px; }
.ha-mitem__fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ha-mitem__fields input { width: 100%; }
.ha-mitem__actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ha-saved { font-size: 11.5px; color: var(--ok); }
.ha-saved:empty { display: none; }

/* history drawer */
.ha-drawer-overlay { justify-content: flex-end; padding: 0; }
.ha-drawer { width: min(440px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; box-shadow: -8px 0 28px rgba(0,0,0,.25); }
.ha-drawer__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.ha-version-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.ha-version-row__head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ha-version-row__title { margin: 6px 0 2px; font-weight: 500; overflow-wrap: anywhere; }
.ha-version-row__current { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.ha-version-row__note { font-size: 13px; color: var(--text-muted); margin-top: 4px; overflow-wrap: anywhere; }

/* categories */
.ha-clist { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.ha-crow { display: grid; grid-template-columns: 36px 36px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.ha-crow--edit { display: block; }
.ha-crow__icon { color: var(--accent); display: inline-flex; justify-content: center; }
.ha-crow__name { font-weight: 600; }
.ha-crow__desc { overflow-wrap: anywhere; }
.ha-switch { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; min-height: 36px; }
.ha-switch input { width: 20px; height: 20px; }
.ha-iconpicker { display: flex; flex-wrap: wrap; gap: 6px; }
.ha-iconpick { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); cursor: pointer; }
.ha-iconpick:hover { border-color: var(--text-faint); color: var(--text); }
.ha-iconpick.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ha-addcat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 20px; }
.ha-addcat__fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* synonyms / import */
.ha-helpbox { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--info); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }
.ha-helpbox p { margin: 6px 0 0; line-height: 1.5; max-width: 80ch; }
.ha-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ha-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ha-table th, .ha-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; overflow-wrap: anywhere; }
.ha-table thead th { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 500; }
.ha-table input { width: 100%; }
.ha-syn__actions { white-space: nowrap; display: flex; gap: 6px; }
.ha-details { margin-top: 10px; }
.ha-details summary { cursor: pointer; font-size: 13.5px; color: var(--accent); min-height: 36px; display: flex; align-items: center; }
.ha-code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; overflow: auto; font-family: var(--font-mono); font-size: 12px; max-height: 320px; }
.ha-import__text { width: 100%; font-family: var(--font-mono); font-size: 12.5px; }
.ha-report { margin-top: 20px; }
.ha-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.ha-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.ha-stat__n { font-family: var(--font-display); font-size: 26px; }
.ha-stat__l { font-size: 12px; color: var(--text-muted); }
.ha-stat.is-ok .ha-stat__n { color: var(--ok); }
.ha-stat.is-bad .ha-stat__n { color: var(--danger); }
.ha-report__block { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.ha-report__block h3 { margin: 0 0 6px; font-size: 13.5px; }
.ha-report__block ul { margin: 0 0 0 18px; padding: 0; font-size: 13.5px; overflow-wrap: anywhere; }
.ha-report__block--bad { border-color: var(--danger); }

/* ---------- phone / tablet ---------- */
@media (max-width: 900px) {
  .ha-editor__grid { grid-template-columns: 1fr; }
  .ha-row { grid-template-columns: 36px minmax(0, 1fr); }
  .ha-row__flags { grid-column: 2; justify-content: flex-start; }
  .ha-row__actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
  .ha-crow { grid-template-columns: 36px 28px minmax(0, 1fr); }
  .ha-crow .ha-switch, .ha-crow .ha-row__actions { grid-column: 1 / -1; }
  .ha-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .ha-topbar { top: -16px; margin: -16px -16px 12px; padding: 8px 16px; }
  .ha-topbar__title { max-width: 100%; }
  .ha-topbar__actions { width: 100%; }
  .ha-topbar__actions .btn { flex: 1 1 auto; justify-content: center; }
  .ha-topbar .btn, .ha-row .btn, .ha-crow .btn, .ha-dialog .btn, .ha-block .btn, .ha-mitem .btn, .ha-section .btn, .ha-addcat .btn, .ha-table .btn, .ha-helpbox .btn, .ha-report .btn, .ha-toolbar .btn, .ha-error .btn, .ha-empty .btn, .ha-banner .btn { min-height: 44px; }
  .ha-iconbtn { min-width: 44px; min-height: 44px; }
  .ha-chip__x { min-width: 32px; min-height: 32px; }
  .ha-check { min-height: 44px; }
  .ha-menu__item { min-height: 44px; }
  .ha-checks { grid-template-columns: 1fr; }
  .ha-addcat__fields { grid-template-columns: 1fr; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { min-height: 44px; font-size: 16px; }
  .ha-chips__input { min-height: 36px; }
  .ha-switch input, .ha-check input { width: 22px; height: 22px; }
  .ha-tab, .ha-subnav__link { min-height: 44px; }
  .ha-mitem { grid-template-columns: 44px 64px minmax(0, 1fr); }
  .ha-toolbar { justify-content: stretch; }
  .ha-toolbar .btn { width: 100%; justify-content: center; }
  .ha-row__actions .btn { flex: 0 0 auto; }
  .ha-dialog__actions .btn { flex: 1 1 auto; justify-content: center; }
  .ha-drawer { width: 100%; }
}
.ha-publink[hidden] { display: none; }
.ha-page a.btn, .ha-row a.btn { text-decoration: none; color: var(--text); }
.ha-page a.btn.btn-primary { color: #1A0D06; }
/* visually-hidden file inputs must never create overflow: pin them inside a positioned page root */
.ha-page, .ha-editor, .ha-dialog, .ha-drawer { position: relative; }
.ha-sr { left: 0; top: 0; }
@media (max-width: 720px) {
  .ha-page .btn, .ha-editor .btn, .ha-drawer .btn, .ha-overlay .btn, .ha-page summary, .ha-editor summary, .ha-menu button { min-height: 44px; }
}
.ha-section__body .kpi-sub { margin: 4px 0 12px; }

/* ---------- Phase H4: Insights ---------- */
.ha-ins-period { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; flex-wrap: wrap; }
.ha-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
/* Not a .btn on purpose: the light theme forces a white background on every non-primary .btn
   (html.theme-light .btn:not(.btn-primary), specificity 0,3,1), which would hide the active state. */
.ha-seg__btn { background: transparent; border: 0; border-right: 1px solid var(--line); color: var(--text-muted); padding: 8px 14px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; min-height: 44px; }
.ha-seg__btn:last-child { border-right: 0; }
.ha-seg__btn:hover:not(.is-on) { background: var(--surface-hover); color: var(--text); }
.ha-seg__btn.is-on { background: var(--accent); color: #1A0D06; }
.ha-seg__btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.ha-seg__btn.is-on:focus-visible { outline-color: #1A0D06; }
.ha-kpi-grid { margin-bottom: 26px; }
.ha-kpi .kpi-value { line-height: 1.1; }
.ha-trend { font-size: 12px; font-weight: 600; margin-top: 8px; color: var(--text-muted); }
.ha-trend--good { color: var(--ok); }
.ha-trend--bad { color: var(--danger); }
html.theme-light .ha-trend--good { color: #0B7A4A; }
html.theme-light .ha-trend--bad { color: #B3173A; }
.ha-ins-section { margin-bottom: 30px; }
.ha-ins-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ha-ins-head .kpi-sub { margin: 2px 0 0; max-width: 62ch; }
.ha-ins-toggle { min-height: 44px; }
.ha-ins-sort { display: flex; align-items: center; gap: 8px; }
.ha-ins-table th[scope="row"] { font-weight: 500; }
.ha-q { font-weight: 600; overflow-wrap: anywhere; }
.ha-q-badge { margin-left: 8px; }
.is-dismissed .ha-q { color: var(--text-muted); font-weight: 500; }
.ha-ins-actions { text-align: right; white-space: normal; }
.ha-ins-actions .btn { margin: 2px 0 2px 6px; vertical-align: middle; }
@media (min-width: 1019px) { .ha-kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.ha-ins-table--opp td:last-child { white-space: normal; }
.ha-pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.ha-pager .kpi-sub { margin: 0 auto 0 0; }
.ha-attn { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); text-decoration: none; white-space: nowrap; }
html:not(.theme-light) .ha-attn { color: #FFB3C2; background: #5A2233; }
html.theme-light .ha-attn { color: #B3173A; background: #FCE8EC; }
.ha-ins-flags { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.ha-ins-edit { font-size: 12.5px; color: var(--text-muted); }
.is-attention { background: var(--danger-soft); }
html.theme-light .is-attention { background: #FEF4F6; }
.ha-linkbtn { background: none; border: 0; padding: 0; margin: 0; color: var(--text); font: inherit; font-weight: 600; text-align: left; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; overflow-wrap: anywhere; }
.ha-linkbtn:hover { color: var(--accent); }
.ha-linkbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
html.theme-light .ha-linkbtn:hover { color: var(--accent-dim); }
.ha-fbline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12.5px; color: var(--text-muted); margin: 2px 0 12px; }
.ha-fbline[hidden] { display: none; }
.ha-fbline__n { display: inline-flex; align-items: center; gap: 3px; color: var(--text); font-weight: 600; }
.ha-fbline .ha-linkbtn { font-size: 12.5px; flex-basis: 100%; text-align: left; justify-content: flex-start; }
.ha-cmt-drawer { width: min(520px, 100%); }
.ha-cmt-sub { margin: 2px 0 0; overflow-wrap: anywhere; }
.ha-cmt-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.ha-cmt { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface-raised); }
.ha-cmt.is-handled { background: transparent; }
.ha-cmt__head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ha-cmt__date { margin: 0 0 0 auto; }
.ha-cmt__article { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; overflow-wrap: anywhere; }
.ha-cmt__text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; line-height: 1.5; font-size: 14px; }
.ha-cmt__foot { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.ha-cmt-more { margin: 6px 0 12px; }
.ha-chipx { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--line-soft); color: var(--text-muted); }
.ha-vote { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.ha-vote--yes { background: var(--ok-soft); color: var(--ok); }
.ha-vote--no { background: var(--danger-soft); color: var(--danger); }
html:not(.theme-light) .ha-vote--yes { color: #7CF0B4; }
html:not(.theme-light) .ha-vote--no { color: #FFA3B6; }
html.theme-light .ha-vote--yes { color: #0B7A4A; }
html.theme-light .ha-vote--no { color: #B3173A; }
.ha-handled { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-muted); }
@media (max-width: 720px) {
  .ha-ins-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ha-ins-table, .ha-ins-table tbody, .ha-ins-table tr, .ha-ins-table th, .ha-ins-table td { display: block; width: 100%; }
  .ha-ins-table tr { padding: 12px; border-bottom: 1px solid var(--line-soft); }
  .ha-ins-table tr:last-child { border-bottom: 0; }
  .ha-ins-table th, .ha-ins-table td { border: 0; padding: 3px 0; }
  .ha-ins-table td { display: flex; justify-content: space-between; gap: 12px; }
  .ha-ins-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 12.5px; flex: none; }
  .ha-ins-table td.ha-ins-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
  .ha-ins-table td.ha-ins-actions::before { content: none; }
  .ha-ins-actions .btn { flex: 1 1 auto; justify-content: center; margin: 0; }
  .ha-linkbtn { min-height: 44px; display: inline-flex; align-items: center; }
  .ha-fbline .ha-linkbtn, .ha-ins-edit { min-height: 44px; display: inline-flex; align-items: center; }
  .ha-seg { width: 100%; }
  .ha-seg__btn { flex: 1 1 auto; }
  .ha-ins-sort { width: 100%; }
  .ha-ins-sort select { flex: 1; }
  .ha-pager .btn { flex: 0 0 auto; }
}

/* ---- Feedback Centre: Help Centre card + chips (Help Centre H5) ----------------------------------
   The light theme forces a white background on every non-primary .btn (specificity 0,3,1), so the
   .fc-btn rules repeat it under html.theme-light to keep the hover/pressed states legible. */
.fc-check { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; min-height: 44px; }
.fc-chip { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-hover); color: var(--text); font-size: 11px; font-weight: 600; vertical-align: middle; }
.fc-chip--help { background: var(--info-soft); border-color: var(--info); color: var(--text); margin-left: 0; }
.fc-chip--needed { border-color: var(--warn); }
.fc-chip--warn { border-color: var(--warn); background: var(--warn-soft); }
.fc-help { padding: 14px 16px; margin-top: 14px; }
.fc-help__head { margin-bottom: 10px; }
.fc-help__body { display: flex; flex-direction: column; gap: 12px; }
.fc-help__row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13.5px; }
.fc-help__label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: block; }
.fc-help__links, .fc-help__results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fc-help__link, .fc-help__result { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.fc-help__link-title, .fc-help__result-text { min-width: 0; overflow-wrap: anywhere; }
.fc-link { color: var(--text); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.fc-input { width: 100%; box-sizing: border-box; min-height: 44px; }
.fc-help__pick { display: flex; flex-direction: column; gap: 6px; }
.fc-help__msg { min-height: 18px; font-size: 13px; color: var(--text-muted); }
.fc-help__msg.is-error { color: var(--danger); font-weight: 600; }
.fc-btn, html.theme-light .btn.fc-btn { min-height: 44px; padding: 0 18px; font-weight: 600; background: var(--surface); color: var(--text); border: 1px solid var(--text-muted); }
.fc-btn:hover:not(:disabled), html.theme-light .btn.fc-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); border-color: var(--text); }
.fc-btn:disabled { opacity: .6; cursor: default; }
.fc-toggle.is-on, html.theme-light .btn.fc-toggle.is-on { background: var(--warn-soft); border-color: var(--warn); color: var(--text); }
@media (max-width: 600px) { .fc-help__link .fc-btn, .fc-help__result .fc-btn { flex: 1 1 100%; } }
.ha-kpi--link { text-decoration: none; color: inherit; display: block; }
.ha-kpi--link:hover { border-color: var(--accent); }
.related-help__link { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
