/* Heartbeat staff portal – design tokens and layout.
   Tokens first so the theme can be swapped (or a dark theme added) without touching components. */

:root {
    color-scheme: light;

    --hb-font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
    --hb-font-display: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, sans-serif;
    --hb-font-mono: "Cascadia Code", "Cascadia Mono", "SFMono-Regular", "JetBrains Mono", Consolas, monospace;

    --hb-size-xs: 0.75rem;
    --hb-size-sm: 0.875rem;
    --hb-size-md: 0.9375rem;
    --hb-size-lg: 1.125rem;
    --hb-size-xl: 1.5rem;
    --hb-size-2xl: 2rem;

    --hb-radius-sm: 8px;
    --hb-radius-md: 12px;
    --hb-radius-lg: 16px;
    --hb-radius-xl: 22px;
    --hb-radius-pill: 999px;

    --hb-space-1: 0.25rem;
    --hb-space-2: 0.5rem;
    --hb-space-3: 0.75rem;
    --hb-space-4: 1rem;
    --hb-space-5: 1.5rem;
    --hb-space-6: 2rem;

    /* Fingers need 44px; a mouse is happy with 40px, so controls only grow on touch screens. */
    --hb-tap-target: 44px;
    --hb-control-height: 40px;

    --hb-brand: #4f46e5;
    --hb-brand-strong: #4338ca;
    --hb-brand-soft: #eef2ff;
    --hb-accent: #7c3aed;
    --hb-brand-gradient: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);
    --hb-ring: 0 0 0 4px rgb(99 102 241 / 22%);

    --hb-canvas: #f5f6fa;
    --hb-surface: #ffffff;
    --hb-surface-alt: #f8f9fc;
    --hb-surface-sunken: #f1f3f8;
    --hb-border: #e5e7ef;
    --hb-border-strong: #d3d7e3;

    --hb-text: #111827;
    --hb-text-muted: #667085;
    --hb-text-inverse: #ffffff;

    --hb-success: #059669;
    --hb-success-soft: #ecfdf5;
    --hb-warning: #c2410c;
    --hb-warning-soft: #fff7ed;
    --hb-danger: #dc2626;
    --hb-danger-soft: #fef2f2;
    --hb-info: #0284c7;
    --hb-info-soft: #f0f9ff;
    --hb-violet: #7c3aed;
    --hb-violet-soft: #f5f3ff;

    --hb-shadow-sm: 0 1px 2px rgb(16 24 40 / 5%);
    --hb-shadow-md: 0 1px 2px rgb(16 24 40 / 4%), 0 4px 12px -2px rgb(16 24 40 / 8%);
    --hb-shadow-lg: 0 2px 4px rgb(16 24 40 / 4%), 0 24px 48px -12px rgb(16 24 40 / 18%);
    --hb-shadow-brand: 0 1px 2px rgb(67 56 202 / 20%), 0 6px 16px -4px rgb(79 70 229 / 45%);

    --hb-sidebar-bg: #0f1222;
    --hb-sidebar-border: rgb(255 255 255 / 6%);
    --hb-sidebar-text: #c9cde0;
    --hb-sidebar-muted: #8a90ad;
    --hb-sidebar-hover: rgb(255 255 255 / 6%);
    --hb-sidebar-active: rgb(129 140 248 / 16%);

    --hb-sidebar-width: 256px;
    --hb-header-height: 64px;
    --hb-content-max: 1400px;

    --hb-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (pointer: coarse) {
    :root {
        --hb-control-height: var(--hb-tap-target);
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;

        --hb-brand: #6366f1;
        --hb-brand-strong: #a5b4fc;
        --hb-brand-soft: rgb(99 102 241 / 16%);
        --hb-ring: 0 0 0 4px rgb(129 140 248 / 28%);

        --hb-canvas: #0a0d16;
        --hb-surface: #121626;
        --hb-surface-alt: #161b2d;
        --hb-surface-sunken: #0e1220;
        --hb-border: #232a40;
        --hb-border-strong: #333c57;

        --hb-text: #e6e8f2;
        --hb-text-muted: #98a0ba;

        --hb-success: #34d399;
        --hb-success-soft: rgb(16 185 129 / 14%);
        --hb-warning: #fbbf24;
        --hb-warning-soft: rgb(245 158 11 / 14%);
        --hb-danger: #f87171;
        --hb-danger-soft: rgb(239 68 68 / 14%);
        --hb-info: #38bdf8;
        --hb-info-soft: rgb(14 165 233 / 14%);
        --hb-violet: #c4b5fd;
        --hb-violet-soft: rgb(139 92 246 / 16%);

        --hb-shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
        --hb-shadow-md: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 16px -4px rgb(0 0 0 / 50%);
        --hb-shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 65%);

        --hb-sidebar-bg: #080a12;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--hb-font-sans);
    font-size: var(--hb-size-md);
    font-feature-settings: "cv11", "ss01", "ss03";
    line-height: 1.55;
    color: var(--hb-text);
    background: var(--hb-canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

::selection {
    background: rgb(99 102 241 / 22%);
}

a {
    color: var(--hb-brand);
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

h1,
h2,
h3 {
    font-family: var(--hb-font-display);
}

/* ---------- shell ---------- */

.hb-shell {
    display: grid;
    grid-template-columns: var(--hb-sidebar-width) 1fr;
    min-height: 100vh;
    min-height: 100dvh;
}

.hb-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-2);
    height: 100vh;
    height: 100dvh;
    padding: var(--hb-space-4) var(--hb-space-3);
    overflow-y: auto;
    color: var(--hb-sidebar-text);
    background:
        radial-gradient(120% 60% at 0% 0%, rgb(99 102 241 / 18%), transparent 60%),
        var(--hb-sidebar-bg);
    border-right: 1px solid var(--hb-sidebar-border);
}

.hb-sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    margin-bottom: var(--hb-space-3);
    padding: var(--hb-space-2);
    border-radius: var(--hb-radius-md);
    font-family: var(--hb-font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
    color: #ffffff;
}

.hb-sidebar__mark {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--hb-brand-gradient);
    box-shadow: var(--hb-shadow-brand), inset 0 1px 0 rgb(255 255 255 / 25%);
    color: var(--hb-text-inverse);
    font-size: var(--hb-size-sm);
    font-weight: 700;
}

.hb-sidebar__mark svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentcolor;
    stroke-width: 2.25;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hb-sidebar__brand small {
    display: block;
    color: var(--hb-sidebar-muted);
    font-size: var(--hb-size-xs);
    font-weight: 500;
    letter-spacing: 0;
}

.hb-nav__label {
    margin: var(--hb-space-2) 0 var(--hb-space-1);
    padding: 0 var(--hb-space-3);
    color: var(--hb-sidebar-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hb-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hb-nav__link {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    min-height: var(--hb-control-height);
    padding: 0 var(--hb-space-3);
    border-radius: var(--hb-radius-sm);
    color: var(--hb-sidebar-text);
    text-decoration: none;
    font-size: var(--hb-size-sm);
    font-weight: 500;
    transition: background 160ms var(--hb-ease), color 160ms var(--hb-ease);
}

.hb-nav__link:hover {
    background: var(--hb-sidebar-hover);
    color: #ffffff;
}

.hb-nav__link.is-active,
.hb-nav__link.active {
    background: var(--hb-sidebar-active);
    color: #ffffff;
    font-weight: 600;
}

.hb-nav__link.is-active::before,
.hb-nav__link.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 9px;
    bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--hb-brand-gradient);
}

.hb-nav__link.is-active .hb-nav__icon,
.hb-nav__link.active .hb-nav__icon {
    stroke: #a5b4fc;
}

.hb-nav__icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    stroke: currentcolor;
    stroke-width: 1.75;
    fill: none;
}

/* A count pill (unread messages); inside the sidebar it marks a module that is not built yet. */
.hb-nav__badge {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 1px 8px;
    border-radius: var(--hb-radius-pill);
    background: var(--hb-brand-gradient);
    color: var(--hb-text-inverse);
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

.hb-sidebar .hb-nav__badge {
    background: rgb(255 255 255 / 8%);
    color: var(--hb-sidebar-muted);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hb-user {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--hb-space-2) var(--hb-space-3);
    margin-top: auto;
    padding: var(--hb-space-3);
    border: 1px solid var(--hb-sidebar-border);
    border-radius: var(--hb-radius-md);
    background: rgb(255 255 255 / 4%);
}

.hb-user__caption {
    min-width: 0;
    color: var(--hb-sidebar-muted);
    font-size: var(--hb-size-xs);
    line-height: 1.4;
}

.hb-user__caption strong {
    display: block;
    overflow: hidden;
    color: #ffffff;
    font-size: var(--hb-size-sm);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hb-user .hb-button {
    grid-column: 1 / -1;
    width: 100%;
    color: var(--hb-sidebar-text);
    border-color: var(--hb-sidebar-border);
}

.hb-user .hb-button:hover:not(:disabled) {
    background: var(--hb-sidebar-hover);
    color: #ffffff;
}

.hb-avatar {
    display: grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--hb-brand-gradient);
    color: var(--hb-text-inverse);
    font-size: var(--hb-size-xs);
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 2px rgb(255 255 255 / 10%);
}

.hb-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background:
        radial-gradient(60% 320px at 100% 0%, rgb(124 58 237 / 6%), transparent 70%),
        radial-gradient(50% 280px at 0% 0%, rgb(79 70 229 / 5%), transparent 70%);
}

.hb-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    height: var(--hb-header-height);
    padding: 0 var(--hb-space-6);
    background: color-mix(in srgb, var(--hb-canvas) 78%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--hb-border) 70%, transparent);
}

.hb-header__title {
    margin: 0;
    font-size: var(--hb-size-lg);
    font-weight: 650;
    letter-spacing: -0.02em;
}

.hb-header > .hb-muted {
    overflow: hidden;
    padding-left: var(--hb-space-3);
    border-left: 1px solid var(--hb-border-strong);
    font-size: var(--hb-size-sm);
    text-overflow: ellipsis;
}

.hb-header__spacer {
    margin-left: auto;
}

.hb-menu-button {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: var(--hb-tap-target);
    min-height: var(--hb-tap-target);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
    cursor: pointer;
}

.hb-content {
    flex: 1;
    width: 100%;
    max-width: var(--hb-content-max);
    padding: var(--hb-space-6);
    margin: 0 auto;
    animation: hb-rise 320ms var(--hb-ease) both;
}

@keyframes hb-rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.hb-scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgb(8 10 18 / 55%);
    backdrop-filter: blur(2px);
    border: 0;
    padding: 0;
    animation: hb-fade 180ms ease both;
}

@keyframes hb-fade {
    from { opacity: 0; }
}

@media (width <= 900px) {
    .hb-shell {
        grid-template-columns: 1fr;
    }

    .hb-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: min(84vw, var(--hb-sidebar-width));
        transform: translateX(-100%);
        transition: transform 240ms var(--hb-ease);
        box-shadow: var(--hb-shadow-lg);
    }

    .hb-sidebar.is-open {
        transform: translateX(0);
    }

    .hb-menu-button {
        display: inline-flex;
    }

    .hb-header {
        padding: 0 var(--hb-space-3);
    }

    .hb-content {
        padding: var(--hb-space-4) var(--hb-space-3);
    }
}

/* ---------- surfaces ---------- */

.hb-card {
    background: var(--hb-surface);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-lg);
    box-shadow: var(--hb-shadow-md);
}

.hb-card:has(> .hb-table) {
    overflow: hidden;
}

.hb-card__body {
    padding: var(--hb-space-5);
}

.hb-stack {
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-4);
}

.hb-content > .hb-stack {
    gap: var(--hb-space-5);
}

.hb-row {
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    flex-wrap: wrap;
}

.hb-grid {
    display: grid;
    gap: var(--hb-space-4);
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.hb-muted {
    color: var(--hb-text-muted);
}

.hb-nowrap {
    white-space: nowrap;
}

.hb-mono {
    font-family: var(--hb-font-mono);
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
}

/* ---------- controls ---------- */

.hb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--hb-space-2);
    min-height: var(--hb-control-height);
    padding: 0 var(--hb-space-4);
    border: 1px solid var(--hb-border-strong);
    border-radius: var(--hb-radius-sm);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
    color: var(--hb-text);
    font-size: var(--hb-size-sm);
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background 160ms var(--hb-ease), border-color 160ms var(--hb-ease), box-shadow 160ms var(--hb-ease), transform 80ms ease, filter 160ms ease;
}

.hb-button:hover:not(:disabled) {
    background: var(--hb-surface-alt);
    border-color: color-mix(in srgb, var(--hb-border-strong) 60%, var(--hb-text-muted));
}

.hb-button:active:not(:disabled) {
    transform: translateY(1px);
}

.hb-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.hb-button--primary {
    border-color: transparent;
    background: var(--hb-brand-gradient);
    box-shadow: var(--hb-shadow-brand), inset 0 1px 0 rgb(255 255 255 / 18%);
    color: var(--hb-text-inverse);
}

.hb-button--primary:hover:not(:disabled) {
    background: var(--hb-brand-gradient);
    border-color: transparent;
    filter: brightness(1.08);
}

.hb-button--ghost {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    color: var(--hb-text-muted);
}

.hb-button--ghost:hover:not(:disabled) {
    border-color: transparent;
    background: var(--hb-surface-sunken);
    color: var(--hb-text);
}

.hb-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--hb-text);
    font-size: 0.8125rem;
    font-weight: 600;
}

.hb-input,
.hb-select,
.hb-textarea {
    width: 100%;
    min-width: 0;
    min-height: var(--hb-control-height);
    padding: var(--hb-space-2) var(--hb-space-3);
    border: 1px solid var(--hb-border-strong);
    border-radius: var(--hb-radius-sm);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
    font-size: var(--hb-size-sm);
    font-weight: 400;
    transition: border-color 160ms var(--hb-ease), box-shadow 160ms var(--hb-ease);
}

.hb-input::placeholder,
.hb-textarea::placeholder {
    color: color-mix(in srgb, var(--hb-text-muted) 75%, transparent);
}

.hb-input:hover,
.hb-select:hover,
.hb-textarea:hover {
    border-color: color-mix(in srgb, var(--hb-border-strong) 55%, var(--hb-text-muted));
}

.hb-input[type="search"] {
    padding-left: 2.25rem;
    background: var(--hb-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a0ba' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 0.75rem center / 16px;
}

.hb-select {
    padding-right: 2.25rem;
    appearance: none;
    background: var(--hb-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a0ba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.75rem center / 16px;
    cursor: pointer;
}

.hb-textarea {
    min-height: 128px;
    padding: var(--hb-space-3);
    line-height: 1.55;
    resize: vertical;
}

.hb-input:focus,
.hb-select:focus,
.hb-textarea:focus {
    outline: none;
    border-color: var(--hb-brand);
    box-shadow: var(--hb-ring);
}

.hb-button:focus-visible,
.hb-nav__link:focus-visible,
.hb-counter:focus-visible,
.hb-ticket-card:focus-visible,
.hb-ticket-link:focus-visible {
    outline: none;
    box-shadow: var(--hb-ring);
}

input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--hb-brand);
}

/* ---------- badges ---------- */

.hb-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: var(--hb-radius-pill);
    background: var(--hb-surface-sunken);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentcolor 18%, transparent);
    color: var(--hb-text-muted);
    font-size: var(--hb-size-xs);
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.hb-badge[class*="hb-badge--"]::before {
    content: "";
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentcolor;
}

.hb-badge--new { background: var(--hb-info-soft); color: var(--hb-info); }
.hb-badge--open { background: var(--hb-brand-soft); color: var(--hb-brand-strong); }
.hb-badge--pending { background: var(--hb-warning-soft); color: var(--hb-warning); }
.hb-badge--onhold { background: var(--hb-surface-sunken); color: var(--hb-text-muted); }
.hb-badge--resolved { background: var(--hb-success-soft); color: var(--hb-success); }
.hb-badge--closed { background: var(--hb-surface-sunken); color: var(--hb-text-muted); }
.hb-badge--urgent { background: var(--hb-danger-soft); color: var(--hb-danger); }
.hb-badge--high { background: var(--hb-warning-soft); color: var(--hb-warning); }
.hb-badge--low { background: var(--hb-surface-sunken); color: var(--hb-text-muted); }
.hb-badge--active { background: var(--hb-success-soft); color: var(--hb-success); }
.hb-badge--inactive { background: var(--hb-surface-sunken); color: var(--hb-text-muted); }

/* A badge that can be taken away again: an app on a user's account. */
.hb-badge__remove {
    margin: 0 -4px 0 2px;
    padding: 0 4px;
    border: 0;
    border-radius: var(--hb-radius-pill);
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.hb-badge__remove:hover:not(:disabled) { background: var(--hb-border); }
.hb-badge__remove:disabled { cursor: default; opacity: 0.5; }

/* ---------- users ---------- */
.hb-callout {
    padding: var(--hb-space-3) var(--hb-space-4);
    border-radius: var(--hb-radius-md);
    font-size: var(--hb-size-sm);
}

.hb-callout--success { background: var(--hb-success-soft); color: var(--hb-success); }
.hb-callout--error { background: var(--hb-danger-soft); color: var(--hb-danger); }

.hb-checks {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hb-space-2) var(--hb-space-4);
}

.hb-check {
    display: inline-flex;
    align-items: center;
    gap: var(--hb-space-2);
    font-weight: 500;
}

.hb-permissions {
    margin: 0;
    padding-left: 1.1em;
    color: var(--hb-text-muted);
    font-weight: 400;
    columns: 2 220px;
}

.hb-select--compact {
    width: auto;
    min-height: 0;
    padding-top: 2px;
    padding-bottom: 2px;
}

.hb-users td { vertical-align: middle; }
.hb-users .hb-select:not(.hb-select--compact) { min-width: 140px; }

.hb-badge--urgent::before {
    box-shadow: 0 0 0 3px color-mix(in srgb, currentcolor 25%, transparent);
}

/* ---------- stat tiles ---------- */

.hb-counters {
    display: grid;
    gap: var(--hb-space-3);
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.hb-counter {
    --hb-tone: var(--hb-brand);
    --hb-tone-soft: var(--hb-brand-soft);

    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "label icon"
        "value icon";
    align-items: center;
    column-gap: var(--hb-space-3);
    padding: var(--hb-space-4);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-lg);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: transform 180ms var(--hb-ease), box-shadow 180ms var(--hb-ease), border-color 180ms var(--hb-ease), background 180ms var(--hb-ease);
}

.hb-counter:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--hb-tone) 35%, var(--hb-border));
    box-shadow: var(--hb-shadow-md);
}

.hb-counter.is-active {
    border-color: var(--hb-tone);
    background: linear-gradient(180deg, var(--hb-tone-soft), var(--hb-surface) 140%);
    box-shadow: inset 0 0 0 1px var(--hb-tone), var(--hb-shadow-md);
}

.hb-counter--brand { --hb-tone: var(--hb-brand); --hb-tone-soft: var(--hb-brand-soft); }
.hb-counter--info { --hb-tone: var(--hb-info); --hb-tone-soft: var(--hb-info-soft); }
.hb-counter--warning { --hb-tone: var(--hb-warning); --hb-tone-soft: var(--hb-warning-soft); }
.hb-counter--danger { --hb-tone: var(--hb-danger); --hb-tone-soft: var(--hb-danger-soft); }
.hb-counter--success { --hb-tone: var(--hb-success); --hb-tone-soft: var(--hb-success-soft); }
.hb-counter--violet { --hb-tone: var(--hb-violet); --hb-tone-soft: var(--hb-violet-soft); }
.hb-counter--neutral { --hb-tone: var(--hb-text-muted); --hb-tone-soft: var(--hb-surface-sunken); }

.hb-counter__icon {
    grid-area: icon;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: var(--hb-radius-md);
    background: var(--hb-tone-soft);
    color: var(--hb-tone);
}

.hb-counter__icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentcolor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hb-counter__value {
    grid-area: value;
    display: block;
    font-family: var(--hb-font-display);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.hb-counter__label {
    grid-area: label;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--hb-text-muted);
    font-size: var(--hb-size-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Tiles without an icon carry their tone as a dot beside the label. */
.hb-counter > .hb-counter__label::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--hb-tone);
}

.hb-counter__icon ~ .hb-counter__label::before {
    display: none;
}

/* On a phone the tiles become one swipeable row, so the tickets are not pushed below the fold. */
@media (width <= 600px) {
    .hb-counters {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(148px, 44%);
        margin: 0 calc(-1 * var(--hb-space-3));
        padding: 2px var(--hb-space-3) var(--hb-space-2);
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: var(--hb-space-3);
        scrollbar-width: none;
    }

    .hb-counters::-webkit-scrollbar {
        display: none;
    }

    .hb-counter {
        scroll-snap-align: start;
    }

    .hb-counter:hover {
        transform: none;
    }

    .hb-counter__icon {
        width: 32px;
        height: 32px;
        border-radius: var(--hb-radius-sm);
    }

    .hb-counter__icon svg {
        width: 16px;
        height: 16px;
    }

    .hb-counter__label {
        white-space: nowrap;
    }
}

/* The same label style doubles as a definition-list term on the ticket page. */
dt.hb-counter__label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.6875rem;
}

/* ---------- ticket queue ---------- */

.hb-queue__filters {
    display: grid;
    gap: var(--hb-space-3);
    grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr));
    align-items: end;
}

.hb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--hb-size-sm);
}

.hb-table th,
.hb-table td {
    padding: 0.875rem var(--hb-space-4);
    text-align: left;
    border-bottom: 1px solid var(--hb-border);
    vertical-align: middle;
}

.hb-table th {
    background: var(--hb-surface-alt);
    color: var(--hb-text-muted);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hb-table tbody tr {
    transition: background 120ms ease;
}

.hb-table tbody tr:last-child td {
    border-bottom: 0;
}

.hb-table tbody tr:hover {
    background: color-mix(in srgb, var(--hb-brand-soft) 55%, transparent);
}

.hb-table td > .hb-muted {
    margin-top: 2px;
    font-size: var(--hb-size-xs);
}

.hb-ticket-link {
    border-radius: 4px;
    font-weight: 600;
    text-decoration: none;
    color: var(--hb-text);
    transition: color 120ms ease;
}

.hb-ticket-link:hover {
    color: var(--hb-brand);
}

.hb-cards {
    display: none;
    gap: var(--hb-space-3);
    padding: var(--hb-space-3);
}

.hb-ticket-card {
    display: block;
    padding: var(--hb-space-4);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.hb-ticket-card:hover {
    border-color: color-mix(in srgb, var(--hb-brand) 35%, var(--hb-border));
    box-shadow: var(--hb-shadow-md);
}

@media (width <= 1100px) {
    .hb-queue__filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .hb-queue__filters > :first-child {
        grid-column: 1 / -1;
    }
}

@media (width <= 900px) {
    .hb-queue__filters {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .hb-table {
        display: none;
    }

    .hb-cards {
        display: grid;
    }
}

/* ---------- ticket detail ---------- */

.hb-ticket-facts {
    gap: var(--hb-space-2);
}

.hb-detail {
    display: grid;
    gap: var(--hb-space-5);
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
}

/* The requester's messages sit on the left and the team's on the right, like any chat. */
.hb-conversation {
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-4);
}

.hb-message {
    align-self: flex-start;
    width: fit-content;
    min-width: min(100%, 16rem);
    max-width: min(100%, 44rem);
    padding: var(--hb-space-3) var(--hb-space-4);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-lg) var(--hb-radius-lg) var(--hb-radius-lg) 6px;
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-sm);
}

.hb-message--agent {
    align-self: flex-end;
    border-color: color-mix(in srgb, var(--hb-brand) 22%, var(--hb-border));
    border-radius: var(--hb-radius-lg) var(--hb-radius-lg) 6px var(--hb-radius-lg);
    background: linear-gradient(180deg, var(--hb-brand-soft), color-mix(in srgb, var(--hb-brand-soft) 40%, var(--hb-surface)));
}

.hb-message--note {
    align-self: stretch;
    max-width: none;
    border: 1px dashed color-mix(in srgb, var(--hb-warning) 45%, var(--hb-border));
    border-radius: var(--hb-radius-md);
    background: var(--hb-warning-soft);
    box-shadow: none;
}

.hb-message__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px var(--hb-space-2);
    align-items: center;
    margin-bottom: 6px;
    font-size: var(--hb-size-xs);
    color: var(--hb-text-muted);
}

.hb-message__meta > span + span:not(.hb-badge)::before {
    content: "·";
    margin-right: var(--hb-space-2);
    opacity: 0.6;
}

.hb-message__author {
    font-weight: 700;
    color: var(--hb-text);
}

.hb-message__body {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.hb-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hb-space-2);
    margin-top: var(--hb-space-3);
}

/* The reply composer stages pictures before the send row; the picker is a label over a hidden input. */
.hb-reply-attachments {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--hb-space-2);
}

.hb-reply-attachments .hb-muted {
    font-size: var(--hb-size-xs);
    line-height: 1.5;
}

.hb-attachment {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    max-width: 18rem;
    padding: var(--hb-space-2);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    color: inherit;
    font-size: var(--hb-size-xs);
    text-decoration: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.hb-attachment:hover {
    border-color: color-mix(in srgb, var(--hb-brand) 40%, var(--hb-border));
    box-shadow: var(--hb-shadow-md);
}

.hb-attachment__image {
    display: block;
    max-width: 100%;
    max-height: 14rem;
    border-radius: var(--hb-radius-sm);
    object-fit: contain;
}

.hb-attachment__thumb {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    border-radius: var(--hb-radius-sm);
}

.hb-attachment__thumb:hover {
    outline: 2px solid var(--hb-brand);
    outline-offset: 2px;
}

.hb-attachment__glyph {
    display: grid;
    place-items: center;
    width: 100%;
    min-width: 8rem;
    height: 3.5rem;
    border-radius: var(--hb-radius-sm);
    background: var(--hb-surface-alt);
    border: 1px dashed var(--hb-border-strong);
    color: var(--hb-text-muted);
    font-size: var(--hb-size-xs);
    font-weight: 700;
    letter-spacing: 0.08em;
}

.hb-attachment__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hb-attachment__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hb-space-2);
    margin-top: var(--hb-space-1);
}

.hb-attachment__action {
    padding: 3px var(--hb-space-2);
    border: 1px solid var(--hb-border);
    border-radius: 6px;
    background: var(--hb-surface-alt);
    color: var(--hb-brand-strong);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

.hb-attachment__action:hover {
    border-color: var(--hb-brand);
    background: var(--hb-brand-soft);
}

.hb-lightbox {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-3);
    padding: var(--hb-space-4);
    background: rgb(8 10 18 / 82%);
    backdrop-filter: blur(6px);
    animation: hb-fade 160ms ease both;
}

.hb-lightbox__bar {
    display: flex;
    align-items: center;
    gap: var(--hb-space-2);
    padding: var(--hb-space-2) var(--hb-space-3);
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-lg);
    font-size: var(--hb-size-sm);
}

.hb-lightbox__name {
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hb-lightbox__stage {
    display: grid;
    place-items: center;
    flex: 1;
    min-height: 0;
    overflow: auto;
    cursor: zoom-out;
}

.hb-lightbox__image {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-lg);
    object-fit: contain;
    cursor: default;
}

.hb-lightbox__frame {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    cursor: default;
}

.hb-attachment__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hb-timeline {
    margin: 0;
    padding: 0 0 0 var(--hb-space-5);
    list-style: none;
    font-size: var(--hb-size-sm);
}

.hb-timeline li {
    position: relative;
    padding-bottom: var(--hb-space-4);
}

.hb-timeline li:last-child {
    padding-bottom: 0;
}

/* The rail is drawn per item so it stops at the last entry instead of trailing below it. */
.hb-timeline li:not(:last-child)::after {
    content: "";
    position: absolute;
    left: calc(-1 * var(--hb-space-5) + 4px);
    top: 16px;
    bottom: -2px;
    width: 1px;
    background: var(--hb-border-strong);
}

.hb-timeline li::before {
    content: "";
    position: absolute;
    left: calc(-1 * var(--hb-space-5));
    top: 6px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--hb-surface);
    box-shadow: inset 0 0 0 2px var(--hb-brand);
}

.hb-timeline li:first-child::before {
    background: var(--hb-brand);
    box-shadow: 0 0 0 4px var(--hb-brand-soft);
}

.hb-timeline .hb-muted {
    font-size: var(--hb-size-xs);
}

@media (width <= 1100px) {
    .hb-detail {
        grid-template-columns: 1fr;
    }
}

/* ---------- states ---------- */

.hb-state {
    display: grid;
    place-items: center;
    gap: var(--hb-space-2);
    padding: var(--hb-space-6) var(--hb-space-4);
    border: 1px dashed var(--hb-border-strong);
    border-radius: var(--hb-radius-lg);
    background: var(--hb-surface);
    text-align: center;
}

.hb-state > p {
    margin: 0;
    max-width: 52ch;
}

/* An icon above the message, tinted by the state's tone; the loading state already has its spinner. */
.hb-state:not(.hb-state--loading)::before {
    --hb-state-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 12h-6l-2 3h-4l-2-3H2'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E");

    content: "";
    width: 40px;
    height: 40px;
    margin-bottom: var(--hb-space-1);
    background: color-mix(in srgb, var(--hb-text-muted) 60%, transparent);
    -webkit-mask: var(--hb-state-icon) center / contain no-repeat;
    mask: var(--hb-state-icon) center / contain no-repeat;
}

.hb-state__title {
    margin: 0;
    font-family: var(--hb-font-display);
    font-size: var(--hb-size-md);
    font-weight: 650;
    letter-spacing: -0.01em;
}

.hb-state--error {
    border-style: solid;
    border-color: color-mix(in srgb, var(--hb-danger) 30%, var(--hb-border));
    background: var(--hb-danger-soft);
}

.hb-state.hb-state--error::before {
    --hb-state-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E");

    background: var(--hb-danger);
}

.hb-state--loading {
    border-style: solid;
    border-color: var(--hb-border);
}

.hb-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--hb-brand-soft);
    border-top-color: var(--hb-brand);
    border-radius: 50%;
    animation: hb-spin 700ms linear infinite;
}

@keyframes hb-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

.hb-skeleton {
    height: 0.875rem;
    border-radius: var(--hb-radius-pill);
    background: linear-gradient(90deg, var(--hb-surface-sunken) 25%, var(--hb-border) 50%, var(--hb-surface-sunken) 75%);
    background-size: 200% 100%;
    animation: hb-shimmer 1.4s ease-in-out infinite;
}

@keyframes hb-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------- login ---------- */

.hb-login {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--hb-canvas);
}

.hb-login__hero {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--hb-space-6);
    padding: clamp(2rem, 5vw, 3.5rem);
    overflow: hidden;
    color: #e0e3f5;
    background:
        radial-gradient(70% 60% at 85% 10%, rgb(124 58 237 / 45%), transparent 65%),
        radial-gradient(60% 55% at 10% 95%, rgb(79 70 229 / 40%), transparent 65%),
        var(--hb-sidebar-bg);
    isolation: isolate;
}

/* A faint grid gives the hero texture without an image request. */
.hb-login__hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgb(255 255 255 / 5%) 1px, transparent 1px),
        linear-gradient(90deg, rgb(255 255 255 / 5%) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(80% 70% at 50% 40%, #000, transparent);
}

.hb-login__brand {
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    color: #ffffff;
    font-family: var(--hb-font-display);
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hb-login__headline {
    max-width: 18ch;
    margin: 0 0 var(--hb-space-4);
    color: #ffffff;
    font-size: clamp(2rem, 3.4vw, 2.875rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.hb-login__headline span {
    background: linear-gradient(90deg, #a5b4fc, #f0abfc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hb-login__lede {
    max-width: 46ch;
    margin: 0;
    color: #b4b9d6;
    font-size: 1.0625rem;
}

.hb-login__points {
    display: grid;
    gap: var(--hb-space-3);
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--hb-size-sm);
}

.hb-login__points li {
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
}

.hb-login__points li::before {
    content: "";
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23c7d2fe' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center / 13px no-repeat,
        rgb(129 140 248 / 22%);
    box-shadow: inset 0 0 0 1px rgb(165 180 252 / 30%);
}

.hb-login__panel {
    display: grid;
    place-items: center;
    padding: var(--hb-space-5) var(--hb-space-4);
}

.hb-login__card {
    width: min(100%, 420px);
    padding: var(--hb-space-6);
    border-radius: var(--hb-radius-xl);
    box-shadow: var(--hb-shadow-lg);
}

.hb-login__card .hb-button--primary {
    min-height: 44px;
    margin-top: var(--hb-space-1);
}

.hb-login__compact-brand {
    display: none;
}

.hb-login__error {
    margin: 0;
    padding: var(--hb-space-3);
    border: 1px solid color-mix(in srgb, var(--hb-danger) 30%, var(--hb-border));
    border-radius: var(--hb-radius-sm);
    background: var(--hb-danger-soft);
    color: var(--hb-danger);
    font-size: var(--hb-size-sm);
}

@media (width <= 960px) {
    .hb-login {
        grid-template-columns: 1fr;
        background:
            radial-gradient(80% 50% at 50% 0%, rgb(99 102 241 / 14%), transparent 70%),
            var(--hb-canvas);
    }

    .hb-login__hero {
        display: none;
    }

    .hb-login__compact-brand {
        display: flex;
    }

    .hb-login__card {
        padding: var(--hb-space-5);
    }
}

/* The cold-load not-found document has no shell around it, so it centres itself. */
.hb-missing {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--hb-space-4);
    background:
        radial-gradient(70% 45% at 50% 0%, rgb(99 102 241 / 12%), transparent 70%),
        var(--hb-canvas);
}

.hb-missing > .hb-state {
    width: min(100%, 480px);
    box-shadow: var(--hb-shadow-lg);
}

.hb-login__title {
    margin: 0 0 var(--hb-space-1);
    font-size: var(--hb-size-xl);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.025em;
}

.hb-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Blazor shows this bar when the circuit fails; it floats as a toast rather than a strip. */
#blazor-error-ui {
    position: fixed;
    right: var(--hb-space-4);
    bottom: var(--hb-space-4);
    left: auto;
    z-index: 100;
    display: none;
    max-width: min(420px, calc(100vw - 2rem));
    padding: var(--hb-space-3) var(--hb-space-4);
    border: 1px solid color-mix(in srgb, var(--hb-danger) 35%, var(--hb-border));
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface);
    box-shadow: var(--hb-shadow-lg);
    color: var(--hb-text);
    font-size: var(--hb-size-sm);
}

#blazor-error-ui a {
    margin-left: var(--hb-space-2);
    font-weight: 600;
}

/* ---------- dashboard ---------- */

a.hb-counter {
    color: inherit;
    text-decoration: none;
}

/* The meter labels are short, so the ticket list takes the wider share; below 900px the panels
   stack, and the per-app table above them then scrolls sideways rather than vanishing. */
.hb-dashboard__split {
    display: grid;
    gap: var(--hb-space-5);
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: start;
}

@media (width <= 900px) {
    .hb-dashboard__split {
        grid-template-columns: minmax(0, 1fr);
    }
}

.hb-dashboard__heading {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.015em;
}

.hb-dashboard__list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hb-dashboard__item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--hb-space-3);
    padding: var(--hb-space-2) var(--hb-space-3);
    margin: 0 calc(-1 * var(--hb-space-3));
    border-radius: var(--hb-radius-sm);
    transition: background 120ms ease;
}

.hb-dashboard__item:hover {
    background: var(--hb-surface-alt);
}

.hb-dashboard__subject {
    color: inherit;
    font-weight: 600;
    overflow: hidden;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hb-dashboard__subject:hover {
    color: var(--hb-brand);
}

.hb-meter {
    display: grid;
    gap: var(--hb-space-4);
}

.hb-meter__row {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr) 40px;
    align-items: center;
    gap: var(--hb-space-3);
    font-size: var(--hb-size-sm);
}

.hb-meter__track {
    display: block;
    height: 10px;
    border-radius: var(--hb-radius-pill);
    background: color-mix(in srgb, var(--hb-text-muted) 14%, transparent);
    overflow: hidden;
}

.hb-meter__fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--hb-brand-gradient);
    transition: width 400ms var(--hb-ease);
}

.hb-meter__fill.is-warn {
    background: linear-gradient(90deg, #fbbf24, #f97316);
}

.hb-meter__fill.is-danger {
    background: linear-gradient(90deg, #fb7185, #dc2626);
}

.hb-meter__value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* The queue swaps its table for cards on a phone; the dashboard has no such fallback, so its table
   stays put and scrolls sideways instead of disappearing. */
.hb-dashboard__table {
    margin: 0 calc(-1 * var(--hb-space-5)) calc(-1 * var(--hb-space-5));
    border-top: 1px solid var(--hb-border);
    overflow-x: auto;
}

.hb-dashboard__table .hb-table {
    display: table;
}

.hb-dashboard__table .hb-table th:first-child,
.hb-dashboard__table .hb-table td:first-child {
    padding-left: var(--hb-space-5);
}

.hb-dashboard__table .hb-table td {
    font-variant-numeric: tabular-nums;
}

/* ---------- diagnostics ---------- */

.hb-diagnostics {
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-md);
    background: var(--hb-surface-alt);
    overflow: hidden;
}

.hb-diagnostics[open] {
    background: var(--hb-surface);
}

.hb-diagnostics__summary {
    display: flex;
    align-items: center;
    gap: var(--hb-space-2);
    flex-wrap: wrap;
    padding: var(--hb-space-3);
    cursor: pointer;
    list-style: none;
    font-size: var(--hb-size-sm);
    transition: background 120ms ease;
}

.hb-diagnostics__summary:hover {
    background: var(--hb-surface-sunken);
}

.hb-diagnostics__summary::-webkit-details-marker {
    display: none;
}

.hb-diagnostics__summary::before {
    content: "";
    width: 7px;
    height: 7px;
    margin: 0 4px 0 2px;
    border-right: 2px solid var(--hb-text-muted);
    border-bottom: 2px solid var(--hb-text-muted);
    transform: rotate(-45deg);
    transition: transform 160ms var(--hb-ease);
}

.hb-diagnostics[open] .hb-diagnostics__summary::before {
    transform: rotate(45deg);
}

.hb-diagnostics__source {
    font-weight: 600;
    color: var(--hb-brand-strong);
}

.hb-diagnostics__body {
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-3);
    padding: var(--hb-space-3);
    border-top: 1px solid var(--hb-border);
}

.hb-diagnostics__facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--hb-space-3);
    margin: 0;
}

.hb-diagnostics__fact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.hb-diagnostics__fact dt {
    color: var(--hb-text-muted);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.hb-diagnostics__fact dd {
    margin: 0;
    font-size: var(--hb-size-sm);
    overflow-wrap: anywhere;
    display: flex;
    align-items: center;
    gap: var(--hb-space-1);
    min-width: 0;
}

.hb-diagnostics__fact-value {
    min-width: 0;
}

/* Copy-to-clipboard affordance beside an id or token: quiet until hovered, then a tick once copied. */
.hb-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: none;
    color: var(--hb-text-muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.hb-copy svg {
    width: 0.95rem;
    height: 0.95rem;
}

.hb-copy:hover {
    color: var(--hb-text);
    background: var(--hb-surface);
    border-color: var(--hb-border-strong);
}

.hb-copy:focus-visible {
    outline: none;
    box-shadow: var(--hb-ring);
}

.hb-copy.is-copied {
    color: var(--hb-success);
    border-color: var(--hb-success);
    background: var(--hb-success-soft);
}

.hb-diagnostics__section {
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-sm);
    background: var(--hb-surface-alt);
    overflow: hidden;
}

.hb-diagnostics__section-summary {
    display: flex;
    align-items: center;
    gap: var(--hb-space-2);
    padding: var(--hb-space-2) var(--hb-space-3);
    cursor: pointer;
    list-style: none;
}

.hb-diagnostics__section-summary::-webkit-details-marker {
    display: none;
}

.hb-diagnostics__section-summary::before {
    content: "";
    width: 6px;
    height: 6px;
    margin-right: 2px;
    border-right: 1.5px solid var(--hb-text-muted);
    border-bottom: 1.5px solid var(--hb-text-muted);
    transform: rotate(-45deg);
    transition: transform 160ms var(--hb-ease);
}

.hb-diagnostics__section[open] > .hb-diagnostics__section-summary::before {
    transform: rotate(45deg);
}

.hb-diagnostics__section-count {
    margin-left: auto;
    padding: 0 var(--hb-space-2);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-pill);
    background: var(--hb-surface);
    color: var(--hb-text-muted);
    font-size: var(--hb-size-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.hb-diagnostics__section > .hb-diagnostics__facts,
.hb-diagnostics__section > .hb-diagnostics__sync,
.hb-diagnostics__section > .hb-diagnostics__empty,
.hb-diagnostics__section > .hb-diagnostics__exception {
    margin: 0 var(--hb-space-3) var(--hb-space-3);
}

.hb-diagnostics__heading {
    margin: 0;
    font-size: var(--hb-size-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--hb-text-muted);
}

.hb-diagnostics__empty {
    margin: 0;
    font-size: var(--hb-size-sm);
}

.hb-diagnostics__sync {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-2);
}

.hb-diagnostics__sync-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px var(--hb-space-3);
    padding: var(--hb-space-2) var(--hb-space-3);
    border-radius: var(--hb-radius-sm);
    border-left: 3px solid var(--hb-success);
    background: var(--hb-surface);
    font-size: var(--hb-size-sm);
}

.hb-diagnostics__sync-row.is-pending {
    border-left-color: var(--hb-warning);
    background: var(--hb-warning-soft);
}

.hb-diagnostics__sync-row.is-clear .hb-diagnostics__sync-count {
    color: var(--hb-success);
}

.hb-diagnostics__sync-row .hb-muted {
    grid-column: 1 / -1;
    font-size: var(--hb-size-xs);
}

.hb-diagnostics__sync-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.hb-diagnostics__sync-count {
    font-weight: 600;
    color: var(--hb-warning);
    white-space: nowrap;
}

.hb-diagnostics__exception {
    border: 1px solid var(--hb-border);
    border-left: 3px solid var(--hb-danger);
    border-radius: var(--hb-radius-sm);
    background: var(--hb-surface);
}

.hb-diagnostics__exception + .hb-diagnostics__exception {
    margin-top: var(--hb-space-2);
}

.hb-diagnostics__exception summary {
    display: flex;
    align-items: center;
    gap: var(--hb-space-3);
    padding: var(--hb-space-2) var(--hb-space-3);
    cursor: pointer;
    font-size: var(--hb-size-sm);
}

.hb-diagnostics__exception-message {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.hb-diagnostics__exception-count {
    flex: 0 0 auto;
    padding: 0 var(--hb-space-2);
    border: 1px solid var(--hb-border);
    border-radius: var(--hb-radius-pill);
    background: var(--hb-surface-alt);
    color: var(--hb-text-muted);
    font-size: var(--hb-size-xs);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hb-diagnostics__exception-count.is-repeated {
    border-color: color-mix(in srgb, var(--hb-danger) 45%, transparent);
    background: var(--hb-danger-soft);
    color: var(--hb-danger);
}

.hb-diagnostics__exception-body {
    display: flex;
    flex-direction: column;
    gap: var(--hb-space-2);
    padding: 0 var(--hb-space-3) var(--hb-space-3);
    font-size: var(--hb-size-sm);
}

.hb-diagnostics__trace {
    margin: 0;
    max-height: 240px;
    overflow: auto;
    padding: var(--hb-space-3);
    border-radius: var(--hb-radius-sm);
    background: #0f1222;
    color: #d6daf0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.55;
}

/* ---------- scrollbars ---------- */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--hb-border-strong) transparent;
}

.hb-sidebar {
    scrollbar-color: rgb(255 255 255 / 14%) transparent;
}
