/* ================================================================
   PERSONAL ERP D6 — RESPONSIVE WORKSPACE
   A compact, task-first layer shared by all four visual themes.
   ================================================================ */

.erp-icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.erp-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    vertical-align: middle;
}

.sidebar-icon .erp-icon,
.mobile-nav-icon {
    width: 19px;
    height: 19px;
}

html[data-theme] .sidebar-icon {
    display: grid;
    place-items: center;
}

html[data-theme] .desktop-topbar {
    min-height: 70px;
    padding: 10px 28px;
}

html[data-theme] .erp-main .page {
    width: 100%;
    max-width: none;
    padding: 28px clamp(24px, 2.2vw, 42px) 52px;
}

html[data-theme] .workspace-home-shell {
    gap: 14px;
}

html[data-theme] .workspace-home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px 24px;
    padding: 24px 28px;
    border-radius: var(--ui-radius-xl);
}

html[data-theme] .workspace-home-hero::after {
    opacity: .35;
}

html[data-theme] .workspace-home-hero-copy {
    align-self: center;
}

html[data-theme] .workspace-home-hero-copy h1 {
    margin: 2px 0 3px;
    font-size: clamp(2.2rem, 3vw, 3.2rem);
    line-height: 1;
}

html[data-theme] .workspace-home-intro {
    max-width: 680px;
    margin: 0;
    font-size: .96rem;
    line-height: 1.45;
}

html[data-theme] .workspace-home-actions {
    align-items: flex-start;
}

html[data-theme] .workspace-home-create {
    display: none;
}

html[data-theme] .workspace-home-customize {
    min-height: 42px;
    padding: 9px 13px;
}

html[data-theme] .workspace-home-pulse {
    grid-column: 1 / -1;
    gap: 8px;
}

html[data-theme] .workspace-pulse-item {
    min-height: 64px;
    padding: 10px 13px;
    border-radius: var(--ui-radius-md);
    box-shadow: none;
}

html[data-theme] .workspace-pulse-item > span {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 11px;
}

html[data-theme] .workspace-pulse-item strong {
    font-size: 1.05rem;
}

html[data-theme] .workspace-home-dashboard {
    gap: 14px;
}

html[data-theme] .workspace-home-dashboard .workspace-widget {
    min-height: 0;
    border-radius: var(--ui-radius-lg);
    box-shadow: none;
}

html[data-theme] .workspace-home-dashboard .workspace-widget-header {
    min-height: 58px;
    padding: 11px 14px;
}

html[data-theme] .workspace-home-dashboard .workspace-widget-kind-icon {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    border-radius: 11px;
}

html[data-theme] .workspace-home-dashboard .workspace-widget-heading-copy .eyebrow {
    display: none;
}

html[data-theme] .workspace-home-dashboard .workspace-widget-heading-copy h2 {
    font-size: 1rem;
}

html[data-theme] .workspace-home-dashboard .workspace-attention-grid {
    gap: 8px;
    padding: 0 14px 14px;
}

html[data-theme] .workspace-home-dashboard .workspace-attention-item {
    min-height: 52px;
    padding: 8px 11px;
    border-radius: 12px;
}

html[data-theme] .workspace-home-dashboard .workspace-object-list,
html[data-theme] .workspace-home-dashboard .workspace-task-row,
html[data-theme] .workspace-home-dashboard .workspace-schedule-row {
    min-height: 0;
}

html[data-theme] .workspace-home-dashboard .workspace-empty,
html[data-theme] .workspace-home-dashboard .workspace-empty-state {
    min-height: 74px;
    padding: 12px;
}

html[data-theme] .workspace-home-dashboard .workspace-widget:has(.workspace-empty),
html[data-theme] .workspace-home-dashboard .workspace-widget:has(.workspace-empty-state) {
    min-height: 0;
}

html[data-theme] .workspace-home-footer-tools {
    margin-top: 2px;
}

/* Desktop task list */
html[data-theme] .d31-page-hero {
    align-items: end;
    margin-bottom: 14px;
}

html[data-theme] .d31-page-hero h1 {
    margin: 2px 0 4px;
    font-size: clamp(2.2rem, 3vw, 3rem);
    line-height: 1;
}

html[data-theme] .d31-page-hero > div > p:last-child {
    max-width: 780px;
    margin-bottom: 0;
}

html[data-theme] .d31-task-summary {
    gap: 8px;
    margin-bottom: 12px;
}

html[data-theme] .d31-metric {
    min-height: 86px;
    padding: 12px 14px;
    border-radius: var(--ui-radius-md);
    box-shadow: none;
}

html[data-theme] .d31-metric strong {
    margin: 2px 0;
    font-size: 1.45rem;
    line-height: 1;
}

html[data-theme] .d43-list-toolbar.d43-task-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 58px;
    margin-bottom: 12px;
    padding: 7px 9px;
}

html[data-theme] .d43-primary-tabs {
    flex: 0 1 auto;
}

html[data-theme] .d43-primary-tabs a {
    min-height: 40px;
    padding: 9px 18px;
}

html[data-theme] .d43-filter-details {
    width: min(100%, 420px);
    margin-left: auto;
}

html[data-theme] .d43-filter-details > summary {
    min-height: 40px;
    padding: 8px 12px;
}

html[data-theme] .d31-create-panel:not([open]) {
    display: none;
}

html[data-theme] .d31-create-panel[open] {
    margin: 0 0 16px;
}

html[data-theme] .d31-list-section {
    margin-top: 18px;
}

html[data-theme] .d31-section-heading {
    min-height: 44px;
    margin-bottom: 7px;
}

html[data-theme] .d31-section-heading .eyebrow {
    margin-bottom: 1px;
}

html[data-theme] .d31-section-heading h2 {
    font-size: 1.22rem;
}

html[data-theme] .d31-task-list {
    gap: 7px;
}

html[data-theme] .d31-task-card {
    min-height: 64px;
    border-radius: var(--ui-radius-md);
    box-shadow: none;
}

html[data-theme] .d31-task-card-body {
    min-height: 62px;
    padding: 8px 12px 8px 8px;
}

html[data-theme] .d31-task-title-row h3 {
    font-size: .94rem;
}

html[data-theme] .d31-task-chips {
    gap: 5px;
    margin-top: 4px;
}

html[data-theme] .d31-chip,
html[data-theme] .d31-priority {
    min-height: 22px;
    padding: 3px 7px;
    font-size: .67rem;
}

html[data-theme] .d31-mini-avatar {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
}

html[data-theme] .d31-task-check {
    width: 31px;
    height: 31px;
}

/* D6 quick create */
html[data-theme] .quick-create-sheet {
    width: min(720px, calc(100vw - 28px));
    max-height: min(84vh, 760px);
    overflow-y: auto;
}

html[data-theme] .quick-create-sheet > header {
    position: sticky;
    z-index: 2;
    top: 0;
    background: var(--ui-surface-raised);
}

html[data-theme] .quick-create-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

html[data-theme] .d6-quick-create-primary {
    padding-bottom: 12px;
}

html[data-theme] .quick-create-grid > a {
    min-height: 82px;
}

html[data-theme] .quick-create-icon {
    display: grid;
    place-items: center;
}

html[data-theme] .d6-quick-create-more {
    margin: 0 18px 18px;
    border-top: 1px solid var(--ui-border);
}

html[data-theme] .d6-quick-create-more > summary {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 2px;
    color: var(--ui-text-muted);
    cursor: pointer;
    list-style: none;
    font-weight: 700;
}

html[data-theme] .d6-quick-create-more > summary::-webkit-details-marker {
    display: none;
}

html[data-theme] .d6-quick-create-more[open] > summary .erp-icon {
    transform: rotate(180deg);
}

html[data-theme] .d6-quick-create-secondary {
    padding: 0;
}

/* Mobile-first layout */
@media (max-width: 1039px) {
    html[data-theme] .erp-main .page {
        padding:
            14px
            14px
            calc(86px + env(safe-area-inset-bottom)) !important;
    }

    html[data-theme] .mobile-bottom-nav {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        min-height: calc(70px + env(safe-area-inset-bottom));
        padding:
            5px
            7px
            calc(5px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--ui-border);
        background: var(--ui-surface-raised);
        box-shadow: 0 -8px 24px rgba(24, 35, 58, .08);
    }

    html[data-theme="dark"] .mobile-bottom-nav {
        box-shadow: 0 -8px 26px rgba(0, 0, 0, .28);
    }

    html[data-theme] .mobile-nav-item {
        min-width: 0;
        min-height: 58px;
        gap: 3px;
        padding: 4px 2px;
        border: 0;
        background: transparent;
        color: var(--ui-text-soft);
        font: inherit;
        cursor: pointer;
    }

    html[data-theme] .mobile-nav-item > span:last-child {
        overflow: hidden;
        max-width: 100%;
        font-size: .67rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html[data-theme] .mobile-nav-item.active {
        color: var(--ui-primary);
    }

    html[data-theme] .mobile-nav-create {
        display: grid;
        place-items: center;
        align-content: center;
    }

    html[data-theme] .mobile-nav-create-icon {
        display: grid;
        width: 46px;
        height: 46px;
        margin-top: -22px;
        place-items: center;
        border: 4px solid var(--ui-surface-raised);
        border-radius: 16px;
        background: var(--ui-primary);
        color: #FFFFFF;
        box-shadow: var(--ui-shadow-md);
    }

    html[data-theme] .mobile-nav-create-icon .erp-icon {
        width: 23px;
        height: 23px;
    }

    html[data-theme] .workspace-home-hero {
        display: block;
        padding: 17px;
        border-radius: 19px;
    }

    html[data-theme] .workspace-home-hero::after {
        display: none;
    }

    html[data-theme] .workspace-home-hero-copy h1 {
        margin: 1px 0 3px;
        font-size: clamp(2.25rem, 11vw, 2.85rem);
    }

    html[data-theme] .workspace-home-intro {
        display: -webkit-box;
        overflow: hidden;
        margin: 0;
        font-size: .9rem;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
    }

    html[data-theme] .workspace-home-actions {
        position: absolute;
        top: 14px;
        right: 14px;
    }

    html[data-theme] .workspace-home-customize {
        width: 42px;
        min-height: 42px;
        padding: 0;
        justify-content: center;
        border-radius: 13px;
    }

    html[data-theme] .workspace-home-customize strong {
        display: none;
    }

    html[data-theme] .workspace-home-pulse {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        margin-top: 14px;
        border-top: 1px solid var(--ui-border);
    }

    html[data-theme] .workspace-pulse-item {
        display: grid;
        min-width: 0;
        min-height: 58px;
        grid-template-columns: 1fr;
        align-content: center;
        gap: 1px;
        padding: 8px 3px;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        text-align: center;
    }

    html[data-theme] .workspace-pulse-item + .workspace-pulse-item {
        border-left: 1px solid var(--ui-border);
    }

    html[data-theme] .workspace-pulse-item > span {
        display: none;
    }

    html[data-theme] .workspace-pulse-item > div {
        display: contents;
    }

    html[data-theme] .workspace-pulse-item small {
        overflow: hidden;
        max-width: 100%;
        font-size: .64rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html[data-theme] .workspace-pulse-item strong {
        grid-row: 1;
        font-size: 1.2rem;
    }

    html[data-theme] .workspace-home-dashboard {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-widget {
        grid-column: 1 / -1;
        border-radius: 17px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-widget-header {
        min-height: 50px;
        padding: 8px 10px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-widget-kind-icon {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
        border-radius: 10px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-widget-heading-copy h2 {
        font-size: .96rem;
    }

    html[data-theme] .workspace-home-dashboard .workspace-attention-grid {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 0 10px 10px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-attention-item {
        min-height: 46px;
        padding: 6px 9px;
    }

    html[data-theme] .workspace-home-dashboard .workspace-attention-item strong {
        width: 30px;
        height: 30px;
        font-size: .9rem;
    }

    html[data-theme] .workspace-home-dashboard .workspace-widget:has(.workspace-empty),
    html[data-theme] .workspace-home-dashboard .workspace-widget:has(.workspace-empty-state) {
        display: none;
    }

    html[data-theme] .workspace-home-footer-tools {
        display: none;
    }

    html[data-theme] .d31-page-hero {
        display: flex;
        align-items: end;
        margin: 2px 0 10px;
    }

    html[data-theme] .d31-page-hero h1 {
        margin: 1px 0 0;
        font-size: clamp(2.2rem, 12vw, 2.8rem);
    }

    html[data-theme] .d31-page-hero > div > p:last-child {
        display: none;
    }

    html[data-theme] .d31-hero-action {
        display: none;
    }

    html[data-theme] .d31-task-summary {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0;
        margin: 0 0 9px;
        border-block: 1px solid var(--ui-border);
    }

    html[data-theme] .d31-metric {
        min-width: 0;
        min-height: 66px;
        padding: 8px 3px;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        text-align: center;
    }

    html[data-theme] .d31-metric + .d31-metric {
        border-left: 1px solid var(--ui-border);
    }

    html[data-theme] .d31-metric span {
        overflow: hidden;
        max-width: 100%;
        font-size: .64rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html[data-theme] .d31-metric strong {
        margin: 1px 0 0;
        font-size: 1.25rem;
    }

    html[data-theme] .d31-metric small {
        display: none;
    }

    html[data-theme] .d43-list-toolbar.d43-task-toolbar {
        min-height: 50px;
        margin-bottom: 9px;
        padding: 5px;
        border-radius: 15px;
    }

    html[data-theme] .d43-primary-tabs {
        display: grid;
        flex: 1;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    html[data-theme] .d43-primary-tabs a {
        min-width: 0;
        min-height: 40px;
        padding: 9px 5px;
        font-size: .75rem;
        text-align: center;
    }

    html[data-theme] .d43-filter-details {
        width: auto;
        margin: 0;
    }

    html[data-theme] .d43-filter-details > summary {
        width: 42px;
        min-height: 40px;
        justify-content: center;
        padding: 0;
    }

    html[data-theme] .d43-filter-details > summary strong,
    html[data-theme] .d43-filter-details > summary i {
        display: none;
    }

    html[data-theme] .d43-filter-details > summary span {
        display: grid;
        place-items: center;
    }

    html[data-theme] .d43-filter-details[open] {
        position: static;
        width: 100%;
    }

    html[data-theme] .d43-filter-details[open] .d43-filter-body {
        position: absolute;
        z-index: 6;
        right: 14px;
        left: 14px;
        margin-top: 8px;
        border: 1px solid var(--ui-border);
        border-radius: 14px;
        background: var(--ui-surface-raised);
        box-shadow: var(--ui-shadow-lg);
    }

    html[data-theme] .d31-create-panel:not([open]) {
        display: none;
    }

    html[data-theme] .d31-create-panel[open] {
        margin-bottom: 12px;
        border-radius: 17px;
    }

    html[data-theme] .d31-list-section {
        margin-top: 13px;
    }

    html[data-theme] .d31-section-heading {
        min-height: 38px;
        margin-bottom: 5px;
    }

    html[data-theme] .d31-section-heading .eyebrow {
        display: none;
    }

    html[data-theme] .d31-section-heading h2 {
        font-size: 1.05rem;
    }

    html[data-theme] .d31-task-list {
        gap: 6px;
    }

    html[data-theme] .d31-task-card {
        min-height: 72px;
        border-radius: 15px;
    }

    html[data-theme] .d31-task-card-body {
        min-height: 70px;
        padding: 8px 9px 8px 5px;
    }

    html[data-theme] .d31-task-title-row {
        align-items: flex-start;
        gap: 5px;
    }

    html[data-theme] .d31-task-title-row h3 {
        font-size: .9rem;
        line-height: 1.2;
    }

    html[data-theme] .d31-task-chips {
        flex-wrap: nowrap;
        overflow: hidden;
        gap: 4px;
        margin-top: 5px;
    }

    html[data-theme] .d31-chip {
        overflow: hidden;
        max-width: 46%;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    html[data-theme] .d31-chip:first-child {
        display: none;
    }

    html[data-theme] .d31-priority {
        flex: 0 0 auto;
    }

    html[data-theme] .d31-mini-avatar {
        display: none;
    }

    html[data-theme] .d31-task-side {
        width: auto;
    }

    html[data-theme] .d31-task-check {
        width: 32px;
        height: 32px;
    }

    html[data-theme] .quick-create-sheet {
        width: calc(100vw - 20px);
        max-height: min(78vh, 640px);
        border-radius: 22px 22px 0 0;
    }

    html[data-theme] .quick-create-sheet > header {
        padding: 14px 16px 10px;
    }

    html[data-theme] .quick-create-sheet > header .eyebrow {
        display: none;
    }

    html[data-theme] .quick-create-grid {
        gap: 7px;
        padding: 9px 12px 12px;
    }

    html[data-theme] .quick-create-grid > a {
        min-height: 72px;
        gap: 8px;
        padding: 10px;
        border-radius: 14px;
    }

    html[data-theme] .quick-create-icon {
        width: 34px;
        height: 34px;
        flex-basis: 34px;
        border-radius: 11px;
    }

    html[data-theme] .quick-create-grid strong {
        font-size: .84rem;
    }

    html[data-theme] .quick-create-grid small {
        font-size: .67rem;
    }

    html[data-theme] .d6-quick-create-more {
        margin: 0 12px 12px;
    }

    html[data-theme] .d6-quick-create-secondary {
        grid-template-columns: 1fr;
        padding: 0;
    }
}

@media (min-width: 1040px) {
    html[data-theme] .erp-shell {
        grid-template-columns: 238px minmax(0, 1fr);
    }

    html[data-theme] .desktop-sidebar {
        width: 238px;
    }

    html[data-theme] .sidebar-brand {
        min-height: 70px;
        padding: 10px 14px;
    }

    html[data-theme] .sidebar-nav {
        padding: 12px 10px;
    }

    html[data-theme] .sidebar-link {
        min-height: 43px;
        padding: 8px 10px;
    }

    html[data-theme] .sidebar-footer {
        padding: 10px 12px;
    }
}

@media (max-width: 420px) {
    html[data-theme] .erp-main .page {
        padding-inline: 10px;
    }

    html[data-theme] .workspace-home-hero {
        padding: 15px;
    }

    html[data-theme] .workspace-home-actions {
        top: 12px;
        right: 12px;
    }

    html[data-theme] .mobile-nav-item > span:last-child {
        font-size: .62rem;
    }

    html[data-theme] .d31-metric span,
    html[data-theme] .workspace-pulse-item small {
        font-size: .59rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html[data-theme] .mobile-nav-create-icon,
    html[data-theme] .d6-quick-create-more > summary .erp-icon {
        transition: none;
    }
}

html[data-theme] .d31-chip .erp-icon {
    width: 12px;
    height: 12px;
    flex-basis: 12px;
}

html[data-theme] .d31-chip.project,
html[data-theme] .d31-chip.date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
