.home-dashboard {
    display: grid;
    gap: .875rem;
    min-width: 0;
    color: var(--dfms-text);
}

.home-dashboard__loading,
.home-dashboard__unavailable {
    display: grid;
    min-width: 0;
    min-height: clamp(12rem, 35dvh, 18rem);
    place-content: center;
    justify-items: center;
    gap: .875rem;
    padding: clamp(1rem, 3vw, 2rem);
    text-align: center;
    background: var(--dfms-surface);
    border: 1px solid var(--dfms-border);
    border-radius: var(--dfms-surface-radius, 1rem);
    box-shadow: var(--dfms-surface-shadow);
}

.home-dashboard__unavailable {
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    width: min(100%, 42rem);
    margin-inline: auto;
    text-align: start;
}

.home-dashboard__unavailable > div {
    min-width: 0;
}

.home-dashboard__unavailable .btn {
    grid-column: 2;
}

.home-dashboard__unavailable h1 {
    color: var(--dfms-text);
    font-size: 1.15rem;
}

.home-dashboard__unavailable p {
    margin-top: .2rem;
}

.home-dashboard__unavailable-icon {
    display: grid;
    width: 2.75rem;
    aspect-ratio: 1;
    place-items: center;
    border-radius: var(--radius-lg);
    color: #b45309;
    background: rgb(245 158 11 / 14%);
    font-size: 1.35rem;
    font-weight: 900;
}

.home-dashboard__spinner {
    width: 2rem;
    aspect-ratio: 1;
    border: .2rem solid var(--dfms-border);
    border-top-color: var(--dfms-primary);
    border-radius: 50%;
    animation: home-dashboard-spin .75s linear infinite;
}

.home-dashboard__spinner--small {
    width: 1rem;
    border-width: .14rem;
}

/* Hero: final intended cascade merged here; no trailing overrides. */
.home-dashboard__hero {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 0;
    min-height: 6.85rem;
    padding: .95rem 1.2rem;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6 0%, #667eea 54%, #764ba2 100%);
    border-radius: var(--dfms-surface-radius, 1rem);
    box-shadow: 0 .8rem 1.75rem rgb(79 70 229 / 22%);
}

.home-dashboard__hero::before,
.home-dashboard__hero::after {
    position: absolute;
    aspect-ratio: 1;
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

.home-dashboard__hero::before {
    inset: -8rem auto auto -5rem;
    width: 15rem;
    border: 2rem solid rgb(255 255 255 / 7%);
}

.home-dashboard__hero::after {
    inset: auto -4rem -8rem auto;
    width: 16rem;
    border: 1px solid rgb(255 255 255 / 22%);
}

.home-dashboard__hero-identity,
.home-dashboard__hero-meta {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    min-width: 0;
}

.home-dashboard__hero-identity {
    flex: 1 1 auto;
}

.home-dashboard__hero-identity > div {
    min-width: 0;
}

.home-dashboard__hero h1 {
    max-width: min(42rem, 62vw);
    overflow: hidden;
    color: #fff;
    font-size: clamp(1.2rem, 2vw, 1.58rem);
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-dashboard__role {
    display: inline-flex;
    max-width: 100%;
    margin-top: .35rem;
    padding: .2rem .5rem;
    overflow: hidden;
    border-radius: .45rem;
    color: #4338ca;
    background: #eef2ff;
    font-size: .7rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-dashboard__hero-meta {
    flex: 0 0 auto;
}

.home-dashboard__refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    gap: .4rem;
    margin: 0;
    padding: .42rem .68rem;
    border: 1px solid rgb(255 255 255 / 35%);
    border-radius: .6rem;
    color: #3730a3;
    background: rgb(255 255 255 / 92%);
    font: inherit;
    font-size: .72rem;
    font-weight: 800;
    line-height: 1.2;
    cursor: pointer;
    transition:
        background-color var(--dfms-transition-fast),
        border-color var(--dfms-transition-fast),
        box-shadow var(--dfms-transition-fast);
}

.home-dashboard__refresh:hover:not(:disabled) {
    background: #fff;
}

.home-dashboard__refresh:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 .2rem rgb(255 255 255 / 24%);
}

.home-dashboard__refresh:disabled {
    cursor: wait;
    opacity: .74;
}

/* Metrics: one layout and one final color treatment for every metric. */
.home-dashboard__metrics {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: .65rem;
    min-width: 0;
}

.home-metric {
    display: grid;
    grid-template-rows: auto minmax(1.72rem, auto) auto;
    justify-items: center;
    align-content: center;
    min-width: 0;
    min-height: 6.7rem;
    gap: .28rem;
    padding: .78rem .65rem .88rem;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    border: 1px solid rgb(255 255 255 / 8%);
    border-radius: .85rem;
    box-shadow: 0 .5rem 1.1rem rgb(79 70 229 / 16%);
    text-align: center;
    transition: border-color var(--dfms-transition-fast), box-shadow var(--dfms-transition-fast);
}

.home-metric:hover {
    box-shadow: 0 .65rem 1.25rem rgb(79 70 229 / 22%);
}

.home-metric__icon {
    display: block;
    width: 1.38rem;
    height: 1.38rem;
    margin: 0;
    padding: .16rem;
    overflow: visible;
    color: #e0e7ff;
    background: transparent;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7px;
}

.home-metric__label {
    align-self: center;
    max-width: 100%;
    min-height: 1.72rem;
    overflow-wrap: anywhere;
    color: #e0e7ff;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1.32;
}

.home-metric strong {
    max-width: 100%;
    overflow: hidden;
    color: #fff;
    font-size: clamp(1.12rem, 1.7vw, 1.45rem);
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Content panels */
.home-dashboard__content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(18rem, .95fr);
    gap: .8rem;
    min-width: 0;
}

.home-panel {
    min-width: 0;
    padding: .95rem;
    background: var(--dfms-surface);
    border: 1px solid var(--dfms-border);
    border-radius: .9rem;
    box-shadow: var(--dfms-surface-shadow);
}

.home-panel__header {
    margin-bottom: .7rem;
    padding-bottom: .7rem;
    border-bottom: 1px solid var(--dfms-border);
}

.home-panel__header > div {
    min-width: 0;
}

.home-panel__header h2 {
    color: var(--dfms-text);
    font-size: 1rem;
}

.home-panel__header p {
    margin-top: .2rem;
    color: var(--dfms-text-muted);
    font-size: .74rem;
    line-height: 1.55;
}

.home-panel--actions {
    display: grid;
    align-content: start;
    gap: .55rem;
}

.home-panel--actions .home-panel__header {
    margin-bottom: 0;
}

.home-action {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    min-height: 3.45rem;
    gap: .6rem;
    padding: .58rem .65rem;
    color: var(--dfms-text);
    background: var(--dfms-surface-muted);
    border: 1px solid var(--dfms-border);
    border-radius: .7rem;
    text-decoration: none;
    transition:
        background-color var(--dfms-transition-fast),
        border-color var(--dfms-transition-fast),
        box-shadow var(--dfms-transition-fast);
}

.home-action:hover,
.home-action:focus-visible {
    background: var(--dfms-primary-soft);
    border-color: var(--dfms-primary);
}

.home-action:focus-visible {
    outline: 2px solid var(--dfms-primary);
    outline-offset: 2px;
    box-shadow: var(--dfms-focus-ring);
}

.home-action--empty {
    cursor: default;
}

.home-action--empty:hover {
    background: var(--dfms-surface-muted);
    border-color: var(--dfms-border);
    box-shadow: none;
}

.home-action--notification {
    border-color: var(--dfms-primary);
}

.home-action__icon {
    display: grid;
    width: 2rem;
    aspect-ratio: 1;
    place-items: center;
    border-radius: .55rem;
    color: var(--dfms-primary);
    background: var(--dfms-primary-soft);
    font-size: 1rem;
}

.home-action__content {
    display: grid;
    min-width: 0;
    gap: .08rem;
}

.home-action__content strong,
.home-action__content small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-action__content strong {
    color: var(--dfms-text);
    font-size: .8rem;
}

.home-action__content small {
    color: var(--dfms-text-muted);
    font-size: .7rem;
}

.home-action__badge {
    display: grid;
    min-width: 1.55rem;
    height: 1.55rem;
    place-items: center;
    padding-inline: .3rem;
    border-radius: 999px;
    color: #fff;
    background: var(--danger);
    font-size: .68rem;
    font-weight: 800;
    line-height: 1;
}

.home-action__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--dfms-primary);
    font-size: 1.05rem;
    line-height: 1;
}

.home-status-list {
    display: grid;
    gap: .5rem;
    margin: 0;
}

.home-status-list > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, auto);
    align-items: center;
    min-width: 0;
    gap: .7rem;
    padding: .62rem .7rem;
    background: var(--dfms-surface-muted);
    border: 1px solid var(--dfms-border);
    border-radius: .68rem;
}

.home-status-list dt {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: .45rem;
    color: var(--dfms-text-muted);
    font-size: .74rem;
    font-weight: 700;
}

.home-status-list dt span {
    flex: 0 0 auto;
    color: var(--dfms-primary);
}

.home-status-list dd {
    min-width: 0;
    max-width: 15rem;
    margin: 0;
    overflow: hidden;
    color: var(--dfms-text);
    font-size: .78rem;
    font-weight: 800;
    text-align: end;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-status-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .5rem;
    border-radius: 999px;
    font-size: .68rem;
}

.home-status-badge::before {
    width: .38rem;
    aspect-ratio: 1;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.home-status-badge--available {
    color: #087c58;
    background: rgb(16 185 129 / 13%);
}

:root[data-theme="dark"] .home-status-badge--available {
    color: #8de4bd;
    background: rgb(6 95 70 / 35%);
}

/* Footer now uses the same surface system instead of a disconnected hard-coded strip. */
.home-dashboard__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    min-height: 2.4rem;
    gap: 1rem;
    padding: .55rem .75rem;
    overflow: hidden;
    color: var(--dfms-text-muted);
    background: var(--dfms-surface-muted);
    border: 1px solid var(--dfms-border);
    border-radius: .75rem;
    font-size: .68rem;
}

.home-dashboard__footer span {
    min-width: 0;
}

.home-dashboard__footer span:last-child {
    overflow: hidden;
    text-align: end;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:root[data-theme="dark"] .home-dashboard__unavailable,
:root[data-theme="dark"] .home-panel {
    background: var(--dfms-surface);
    border-color: var(--dfms-border);
}

:root[data-theme="dark"] .home-action,
:root[data-theme="dark"] .home-status-list > div,
:root[data-theme="dark"] .home-dashboard__footer {
    background: var(--dfms-surface-muted);
    border-color: var(--dfms-border);
}

:root[data-theme="dark"] .home-dashboard__hero {
    box-shadow: 0 .8rem 1.75rem rgb(0 0 0 / 28%);
}

@media (max-width: 90rem) {
    .home-dashboard__metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 64rem) {
    .home-dashboard__hero {
        min-height: 0;
    }

    .home-dashboard__hero h1 {
        max-width: min(28rem, 68vw);
    }

    .home-dashboard__content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 42rem) {
    .home-dashboard {
        gap: .65rem;
    }

    .home-dashboard__hero {
        align-items: stretch;
        flex-direction: column;
        padding: 1rem;
    }

    .home-dashboard__hero h1 {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-dashboard__role {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-dashboard__hero-meta {
        justify-content: flex-start;
    }

    .home-dashboard__metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .5rem;
    }

    .home-metric {
        min-height: 6rem;
        padding: .7rem .55rem .8rem;
    }

    .home-metric__label {
        min-height: 1.55rem;
        font-size: .68rem;
    }

    .home-metric strong {
        font-size: 1.05rem;
    }

    .home-panel {
        padding: .75rem;
    }

    .home-action__content strong,
    .home-action__content small {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-status-list > div {
        grid-template-columns: 1fr;
        gap: .28rem;
    }

    .home-status-list dd {
        max-width: 100%;
        text-align: start;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-dashboard__footer {
        align-items: flex-start;
        flex-direction: column;
        gap: .2rem;
    }

    .home-dashboard__footer span:last-child {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .home-dashboard__unavailable {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .home-dashboard__unavailable .btn {
        grid-column: auto;
    }
}

@media (max-width: 34rem) {
    .home-dashboard__refresh {
        width: 100%;
        min-height: var(--dfms-control-height);
    }

    .home-action {
        grid-template-columns: 2rem minmax(0, 1fr) auto;
    }
}

@media (max-width: 22.5rem) {
    .home-dashboard__metrics {
        grid-template-columns: 1fr;
    }
}

@media (max-height: 32rem) and (max-width: 64rem) {
    .home-dashboard__loading,
    .home-dashboard__unavailable {
        min-height: 10rem;
    }

    .home-dashboard__hero {
        padding-block: .75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-dashboard__spinner {
        animation: none;
    }

    .home-metric,
    .home-action,
    .home-dashboard__refresh {
        transition: none;
    }
}

@keyframes home-dashboard-spin {
    to { transform: rotate(360deg); }
}
