html, body {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

/* First-paint splash (#981): covers the blank gap before the InteractiveServer circuit
   connects. Hidden the instant Blazor mounts a layout root, so it never overlaps real
   content or interferes with interaction. */
#app-loading {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--color-background);
    color: var(--color-text-secondary, var(--color-text));
}

#app-loading .app-loading-spinner {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    border: 4px solid color-mix(in srgb, var(--color-primary) 15%, transparent);
    border-top-color: var(--color-primary);
    animation: app-loading-spin 0.8s linear infinite;
}

#app-loading .app-loading-text {
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

@keyframes app-loading-spin {
    to { transform: rotate(360deg); }
}

/* Hide the splash as soon as Blazor renders ANY page content into <body>: its layout/page root
   becomes a non-script element child (before interactivity the only element children of <body>
   are #app-loading and <script>s). Structural rather than per-layout-class so a new EmptyLayout
   page — .landing-page (marketing), .agreement-doc (agreement preview), etc. — can never get
   stuck behind the overlay (#981 review). */
body:has(> :not(#app-loading):not(script):not(style)) #app-loading {
    display: none;
}

/* Fallback: browsers without :has() can't run the hide rule above, so never show the
   overlay there — it would otherwise remain a full-screen block forever. This reverts to
   the pre-existing blank gap on those browsers rather than trapping the user behind the splash. */
@supports not selector(:has(*)) {
    #app-loading {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #app-loading .app-loading-spinner {
        animation: none;
    }
}

/* EPIC #706 Phase 7 (#713) — drag-drop reorder visual state + chart wrapper hooks. */
.hl-reorder-dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.hl-reorder-over {
    outline: 2px dashed var(--color-primary);
    outline-offset: 2px;
}

.hl-chart-wrapper {
    width: 100%;
}

.hl-chart-wrapper:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* <FocusOnNavigate Selector="h1"> moves focus to the page heading after navigation so
   screen readers announce the new page (#980). Blazor gives the h1 tabindex="-1", so it
   is never reachable by Tab — the only thing that focuses it is that programmatic move.

   Chromium decides on its own whether that move earns a :focus-visible ring, and on a
   FRESH DOCUMENT — no interaction yet — it says yes. So every page drew a browser outline
   box around its title on load, mouse users included. Measured in-browser:

       fresh page load     → :focus-visible TRUE   ← the bug
       keyboard-driven nav → :focus-visible TRUE   ← ring is correct here
       mouse-driven nav    → :focus-visible FALSE  ← handled by the first rule below

   The first two are identical to :focus-visible, so CSS alone cannot tell them apart.
   js/focus-modality.js records what the user last did; the ring is shown only when that
   was the keyboard. */
h1:focus:not(:focus-visible) {
    outline: none;
}

/* No interaction yet (fresh load) or last input was a pointer → no ring. */
:root:not([data-input-modality="keyboard"]) h1:focus {
    outline: none;
}

/* Keyboard-driven navigation → show where focus went. currentColor because this same rule
   covers headings on the light app pages and on the dark marketing/legal heroes; anything
   fixed would vanish against one of them. */
:root[data-input-modality="keyboard"] h1:focus {
    outline: 2px solid currentColor;
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--color-primary);
    border: 1px solid var(--color-primary-strong);
    color: var(--color-surface);
}

.btn-primary:hover {
    background: var(--color-primary-strong);
}

.btn-outline {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem rgba(11, 59, 104, 0.15);
}

.validation-message {
    color: var(--color-danger);
}

.blazor-error-boundary {
    background: var(--color-danger);
    padding: 0.75rem 1rem;
    color: var(--color-surface);
    border-radius: var(--radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.actions-col {
    width: 150px;
}

.filter-select {
    max-width: 240px;
}

.pill-dot-warning {
    background: var(--color-warning);
}

/* Notification Bell Component */
.notification-bell-container {
    position: relative;
}

.notification-bell-button {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-bell-button:hover {
    background: var(--color-surface-strong);
}

.bell-icon {
    font-size: 1.25rem;
}

.notification-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: var(--color-danger);
    color: var(--color-surface);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
}

.notification-dropdown {
    position: absolute;
    top: 3rem;
    right: 0;
    width: 400px;
    max-height: 600px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.notification-dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.notification-dropdown-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.notification-tab-button {
    background: transparent;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.notification-tab-button:hover {
    background: var(--color-surface-strong);
}

.notification-tab-button.active {
    background: var(--color-primary);
    color: var(--color-surface);
}

.notification-list {
    overflow-y: auto;
    max-height: 500px;
}

.notification-loading,
.notification-empty {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.notification-type-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.notification-type-info {
    background: var(--color-info);
    color: var(--color-surface);
}

.notification-type-billing {
    background: var(--color-primary);
    color: var(--color-surface);
}

.notification-type-alert {
    background: var(--color-warning);
    color: var(--color-surface);
}

.notification-type-workorder {
    background: var(--color-secondary);
    color: var(--color-surface);
}

.notification-type-system {
    background: var(--color-text-muted);
    color: var(--color-surface);
}

.notification-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.notification-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--color-text);
}

.notification-item-message {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem 0;
}

.notification-item-actions {
    display: flex;
    gap: 0.5rem;
}

.notification-action-button {
    background: transparent;
    border: 1px solid var(--color-border);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--color-text);
}

.notification-action-button:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

@media (max-width: 768px) {
    .notification-dropdown {
        width: 100vw;
        max-width: 400px;
        right: -1rem;
    }
}
