/* ================================================================
   PERSONAL ERP D3.1 — DAILY CORE
   Tasks · Calendar · Attention · Daily Workspace
   ================================================================ */

.d31-page-hero {
    display: grid;
    gap: 15px;
    margin-bottom: 15px;
}

.d31-page-hero h1 {
    margin: 3px 0 6px;
    color: var(--ui-text);
    font-size: clamp(30px, 7vw, 46px);
    line-height: 1.02;
    letter-spacing: -.04em;
}

.d31-page-hero p:not(.eyebrow) {
    max-width: 690px;
    margin: 0;
    color: var(--ui-text-muted);
    font-size: 10px;
    line-height: 1.55;
}

.d31-hero-action {
    align-self: center;
    justify-self: start;
    margin: 0 !important;
}

/* ---------------------------------------------------------------
   Summary / metrics
   --------------------------------------------------------------- */

.d31-task-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.d31-metric {
    display: grid;
    min-height: 102px;
    align-content: space-between;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-metric > span {
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 850;
}

.d31-metric > strong {
    margin: 4px 0;
    color: var(--ui-text);
    font-size: 27px;
    line-height: 1;
}

.d31-metric > small {
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-metric.is-primary {
    border-color: color-mix(
        in srgb,
        var(--ui-primary) 24%,
        var(--ui-border)
    );
    background:
        linear-gradient(
            145deg,
            var(--ui-primary-soft),
            var(--ui-surface)
        );
}

.d31-metric.is-primary > strong {
    color: var(--ui-primary);
}

.d31-metric.is-danger {
    border-color: color-mix(
        in srgb,
        var(--ui-danger) 26%,
        var(--ui-border)
    );
    background:
        linear-gradient(
            145deg,
            var(--ui-danger-soft),
            var(--ui-surface)
        );
}

.d31-metric.is-danger > strong {
    color: var(--ui-danger);
}

/* ---------------------------------------------------------------
   Filters
   --------------------------------------------------------------- */

.d31-control-panel {
    display: grid;
    gap: 12px;
    margin-bottom: 12px;
}

.d31-filter-form {
    display: grid;
    gap: 8px;
}

.d31-filter-form label {
    display: grid;
    gap: 5px;
}

.d31-filter-form label > span {
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 800;
}

.d31-filter-form select {
    min-height: 40px;
}

.d31-filter-form button {
    margin: 0 !important;
}

.d31-clear-filter {
    align-self: center;
    justify-self: start;
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 800;
    text-decoration: none;
}

.d31-segmented-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: var(--ui-bg-subtle);
}

.d31-segmented-links a {
    display: grid;
    min-height: 36px;
    place-items: center;
    border-radius: 9px;
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 850;
    text-decoration: none;
}

.d31-segmented-links a.active {
    background: var(--ui-surface);
    color: var(--ui-primary);
    box-shadow: var(--ui-shadow-sm);
}

/* ---------------------------------------------------------------
   Unified create / edit panel
   --------------------------------------------------------------- */

.d31-create-panel {
    margin-bottom: 16px;
    overflow: hidden;
    padding: 0 !important;
}

.d31-create-panel > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
}

.d31-create-panel > summary::-webkit-details-marker {
    display: none;
}

.d31-create-panel > summary:hover {
    background: var(--ui-surface-soft);
}

.d31-create-panel > summary > span:nth-child(2) strong,
.d31-create-panel > summary > span:nth-child(2) small {
    display: block;
}

.d31-create-panel > summary > span:nth-child(2) strong {
    color: var(--ui-text);
    font-size: 10px;
}

.d31-create-panel > summary > span:nth-child(2) small {
    margin-top: 3px;
    color: var(--ui-text-muted);
    font-size: 8px;
}

.d31-create-panel > summary > i {
    color: var(--ui-text-soft);
    font-size: 12px;
    font-style: normal;
    transition: transform 150ms ease;
}

.d31-create-panel[open] > summary > i {
    transform: rotate(180deg);
}

.d31-summary-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 11px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 16px;
    font-weight: 900;
}

.d31-form {
    display: grid !important;
    gap: 10px !important;
    padding: 0 12px 13px;
    border-top: 1px solid var(--ui-border);
}

.d31-form-section {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: 13px;
    background: var(--ui-surface-soft);
}

.d31-form-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--ui-border);
}

.d31-form-section-title > span {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    border-radius: 9px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 9px;
    font-weight: 900;
}

.d31-form-section-title strong,
.d31-form-section-title small {
    display: block;
}

.d31-form-section-title strong {
    color: var(--ui-text);
    font-size: 9px;
}

.d31-form-section-title small {
    margin-top: 2px;
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-form-grid {
    display: grid;
    gap: 9px;
}

.d31-form label {
    display: grid !important;
    gap: 5px !important;
    margin: 0 !important;
}

.d31-form label > span {
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 800;
}

.d31-form textarea {
    resize: vertical;
}

.d31-form select[multiple] {
    min-height: 96px;
}

.d31-checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 8px !important;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    background: var(--ui-surface);
}

.d31-checkbox-row input {
    width: 17px;
    height: 17px;
    margin: 0;
}

.d31-form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 3px;
}

.d31-form-actions button {
    width: 100%;
    margin: 0 !important;
}

/* ---------------------------------------------------------------
   Task list
   --------------------------------------------------------------- */

.d31-list-section {
    display: grid;
    gap: 8px;
    margin-top: 19px;
    scroll-margin-top: 78px;
}

.d31-section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
}

.d31-section-heading h2 {
    margin: 2px 0 0;
    color: var(--ui-text);
    font-size: 17px;
    line-height: 1.15;
}

.d31-section-heading > span {
    display: grid;
    min-width: 30px;
    height: 30px;
    place-items: center;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 9px;
    font-weight: 900;
}

.d31-section-heading.danger > span {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.d31-task-list {
    display: grid;
    gap: 7px;
}

.d31-task-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
}

.d31-task-card:hover {
    border-color: var(--ui-border-strong);
    box-shadow: var(--ui-shadow-md);
}

.d31-task-check-form {
    display: grid;
    align-items: start;
    padding: 13px 0 0 11px;
}

.d31-task-check {
    display: grid;
    width: 25px;
    height: 25px;
    place-items: center;
    border: 2px solid var(--ui-border-strong);
    border-radius: 8px;
    background: var(--ui-surface);
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    cursor: pointer;
}

.d31-task-card.completed .d31-task-check {
    border-color: var(--ui-success);
    background: var(--ui-success);
}

.d31-task-card-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-width: 0;
    padding: 11px;
    color: var(--ui-text);
    text-decoration: none;
}

.d31-task-main {
    min-width: 0;
}

.d31-task-title-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.d31-task-title-row h3 {
    min-width: 0;
    flex: 1;
    margin: 1px 0 0;
    color: var(--ui-text);
    font-size: 11px;
    line-height: 1.35;
}

.d31-task-card.completed h3 {
    color: var(--ui-text-soft);
    text-decoration: line-through;
}

.d31-priority {
    flex: 0 0 auto;
    padding: 4px 6px;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 6px;
    font-weight: 900;
    line-height: 1;
}

.d31-priority-high,
.d31-priority-urgent {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.d31-priority-medium,
.d31-priority-normal {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.d31-priority-low {
    background: var(--ui-success-soft);
    color: var(--ui-success);
}

.d31-task-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.d31-chip {
    max-width: 100%;
    overflow: hidden;
    padding: 4px 6px;
    border-radius: 7px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 7px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-chip.project {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
}

.d31-chip.date {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.d31-chip.muted {
    color: var(--ui-text-soft);
}

.d31-task-side {
    display: flex;
    align-items: center;
    gap: 7px;
}

.d31-mini-avatar {
    display: grid;
    width: 27px;
    height: 27px;
    place-items: center;
    border-radius: 50%;
    background:
        linear-gradient(
            145deg,
            var(--ui-primary),
            var(--ui-purple)
        );
    color: #fff;
    font-size: 8px;
    font-weight: 900;
}

.d31-row-arrow {
    color: var(--ui-text-soft);
    font-size: 15px;
}

.d31-empty-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 30px !important;
    text-align: center;
}

.d31-empty-state > span {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 15px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 19px;
    font-weight: 900;
}

.d31-empty-state > strong {
    color: var(--ui-text);
}

.d31-empty-state > p {
    max-width: 420px;
    margin: 0 0 3px;
    color: var(--ui-text-muted);
    font-size: 9px;
    line-height: 1.5;
}

/* ---------------------------------------------------------------
   Detail hero
   --------------------------------------------------------------- */

.d31-detail-hero {
    display: grid;
    gap: 14px;
    margin-top: 10px;
    padding: 17px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-xl);
    background:
        linear-gradient(
            145deg,
            var(--ui-surface),
            var(--ui-surface-soft)
        );
    box-shadow: var(--ui-shadow-md);
}

.d31-detail-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.d31-task-label-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.d31-status-pill,
.d31-visibility-pill {
    padding: 5px 8px;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 7px;
    font-weight: 850;
}

.d31-status-pill {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
}

.d31-detail-hero h1 {
    margin: 0;
    color: var(--ui-text);
    font-size: clamp(25px, 6.5vw, 40px);
    line-height: 1.08;
    letter-spacing: -.035em;
}

.d31-detail-description {
    max-width: 850px;
    margin: -2px 0 0;
    color: var(--ui-text-muted);
    font-size: 10px;
    line-height: 1.65;
}

.d31-person-chip {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid var(--ui-border);
    border-radius: 11px;
    background: var(--ui-surface);
}

.d31-person-chip > span {
    display: grid;
    width: 31px;
    height: 31px;
    place-items: center;
    border-radius: 50%;
    background:
        linear-gradient(
            145deg,
            var(--ui-primary),
            var(--ui-purple)
        );
    color: #fff;
    font-size: 9px;
    font-weight: 900;
}

.d31-person-chip small,
.d31-person-chip strong {
    display: block;
}

.d31-person-chip small {
    color: var(--ui-text-soft);
    font-size: 6px;
}

.d31-person-chip strong {
    margin-top: 2px;
    max-width: 145px;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-detail-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.d31-detail-facts > div,
.d31-detail-facts > a {
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    background: var(--ui-surface);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-detail-facts small,
.d31-detail-facts strong {
    display: block;
}

.d31-detail-facts small {
    color: var(--ui-text-soft);
    font-size: 6px;
}

.d31-detail-facts strong {
    margin-top: 4px;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-detail-facts > a strong {
    color: var(--ui-primary);
}

.d31-participants-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}

.d31-participants-row > small {
    margin-right: 2px;
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-participants-row > span {
    padding: 5px 7px;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 7px;
}

.d31-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 3px;
}

.d31-detail-actions form,
.d31-detail-actions a,
.d31-detail-actions button {
    margin: 0 !important;
}

.d31-detail-actions form {
    flex: 1 1 170px;
}

.d31-detail-actions form button {
    width: 100%;
}

.d31-detail-actions > a {
    flex: 1 1 120px;
}

.d31-detail-grid {
    display: grid;
    gap: 11px;
    margin-top: 11px;
}

.d31-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.d31-card-heading h2 {
    margin: 2px 0 0;
    color: var(--ui-text);
    font-size: 15px;
}

.d31-count-badge {
    display: grid;
    min-width: 34px;
    height: 30px;
    place-items: center;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 8px;
    font-weight: 900;
}

.d31-progress-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    margin: 12px 0;
}

.d31-progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
}

.d31-progress-value {
    height: 100%;
    border-radius: inherit;
    background: var(--ui-success);
}

.d31-progress-wrap > strong {
    color: var(--ui-success);
    font-size: 8px;
}

.d31-checklist-add {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
    margin-top: 12px;
}

.d31-checklist-add button {
    margin: 0 !important;
}

.d31-checklist-list {
    display: grid;
    gap: 5px;
    margin-top: 9px;
}

.d31-checklist-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 43px;
    padding: 6px 7px;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    background: var(--ui-surface-soft);
}

.d31-checklist-item > span {
    color: var(--ui-text);
    font-size: 9px;
    line-height: 1.35;
}

.d31-checklist-item.completed > span {
    color: var(--ui-text-soft);
    text-decoration: line-through;
}

.d31-checklist-toggle {
    display: grid;
    width: 25px;
    height: 25px;
    place-items: center;
    border: 2px solid var(--ui-border-strong);
    border-radius: 8px;
    background: var(--ui-surface);
    color: #fff;
    font-size: 9px;
    cursor: pointer;
}

.d31-checklist-item.completed .d31-checklist-toggle {
    border-color: var(--ui-success);
    background: var(--ui-success);
}

.d31-icon-danger {
    display: grid;
    width: 27px;
    height: 27px;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ui-text-soft);
    font-size: 15px;
    cursor: pointer;
}

.d31-icon-danger:hover {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.d31-inline-empty {
    padding: 13px;
    border: 1px dashed var(--ui-border-strong);
    border-radius: 10px;
    color: var(--ui-text-soft);
    font-size: 8px;
    text-align: center;
}

.d31-definition-list {
    display: grid;
    gap: 0;
    margin: 10px 0 0;
}

.d31-definition-list > div {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--ui-border);
}

.d31-definition-list > div:last-child {
    border-bottom: 0;
}

.d31-definition-list dt {
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-definition-list dd {
    margin: 0;
    color: var(--ui-text);
    font-size: 8px;
    font-weight: 800;
    text-align: right;
}

.d31-edit-panel {
    margin-top: 11px;
}

/* ---------------------------------------------------------------
   Calendar
   --------------------------------------------------------------- */

.d31-calendar-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
    padding: 9px !important;
}

.d31-calendar-toolbar > div {
    min-width: 0;
    text-align: center;
}

.d31-calendar-toolbar > div strong {
    display: block;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-calendar-nav {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--ui-border);
    border-radius: 10px;
    background: var(--ui-surface-soft);
    color: var(--ui-text-muted);
    text-decoration: none;
}

.d31-calendar-today {
    display: grid;
    min-height: 34px;
    place-items: center;
    padding: 0 9px;
    border-radius: 9px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 8px;
    font-weight: 850;
    text-decoration: none;
}

.d31-week-strip {
    display: grid;
    grid-auto-columns: minmax(56px, 1fr);
    grid-auto-flow: column;
    gap: 5px;
    overflow-x: auto;
    padding: 2px 1px 8px;
    scrollbar-width: none;
}

.d31-week-strip::-webkit-scrollbar {
    display: none;
}

.d31-week-strip > a {
    display: grid;
    min-height: 70px;
    place-items: center;
    align-content: center;
    gap: 2px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: var(--ui-surface);
    color: var(--ui-text-muted);
    text-decoration: none;
}

.d31-week-strip > a small {
    color: inherit;
    font-size: 6px;
    font-weight: 800;
    text-transform: uppercase;
}

.d31-week-strip > a strong {
    color: var(--ui-text);
    font-size: 15px;
}

.d31-week-strip > a span {
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-week-strip > a.today {
    border-color: color-mix(
        in srgb,
        var(--ui-primary) 32%,
        var(--ui-border)
    );
}

.d31-week-strip > a.selected {
    border-color: var(--ui-primary);
    background: var(--ui-primary);
    color: #fff;
    box-shadow: var(--ui-shadow-md);
}

.d31-week-strip > a.selected small,
.d31-week-strip > a.selected strong,
.d31-week-strip > a.selected span {
    color: #fff;
}

.d31-calendar-week {
    display: grid;
    gap: 8px;
}

.d31-calendar-day {
    overflow: hidden;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-md);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
}

.d31-calendar-day.today {
    border-color: color-mix(
        in srgb,
        var(--ui-primary) 28%,
        var(--ui-border)
    );
}

.d31-calendar-day > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--ui-border);
    background: var(--ui-surface-soft);
}

.d31-calendar-day > header h2 {
    margin: 2px 0 0;
    color: var(--ui-text);
    font-size: 12px;
}

.d31-calendar-day > header > span {
    display: grid;
    min-width: 27px;
    height: 27px;
    place-items: center;
    border-radius: 999px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 8px;
    font-weight: 900;
}

.d31-event-stack {
    display: grid;
    gap: 5px;
    padding: 7px;
}

.d31-event-card {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--ui-border);
    border-left: 3px solid var(--ui-primary);
    border-radius: 10px;
    background: var(--ui-surface-soft);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-event-card.shared {
    border-left-color: var(--ui-purple);
}

.d31-event-time {
    display: grid;
    align-content: start;
}

.d31-event-time strong {
    color: var(--ui-text);
    font-size: 9px;
}

.d31-event-time small {
    margin-top: 3px;
    color: var(--ui-text-soft);
    font-size: 6px;
}

.d31-event-body {
    min-width: 0;
}

.d31-event-body > strong {
    display: block;
    overflow: hidden;
    color: var(--ui-text);
    font-size: 9px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.d31-event-meta span {
    max-width: 100%;
    overflow: hidden;
    padding: 3px 5px;
    border-radius: 6px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 6px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-event-card > i {
    align-self: center;
    color: var(--ui-text-soft);
    font-size: 13px;
    font-style: normal;
}

.d31-calendar-empty {
    display: grid;
    min-height: 56px;
    place-items: center;
    align-content: center;
    gap: 2px;
    border: 1px dashed var(--ui-border);
    border-radius: 10px;
}

.d31-calendar-empty span {
    color: var(--ui-border-strong);
    font-size: 18px;
}

.d31-calendar-empty small {
    color: var(--ui-text-soft);
    font-size: 7px;
}

.d31-related-object {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border: 1px solid var(--ui-border);
    border-radius: 11px;
    background: var(--ui-surface);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-related-object > span {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 9px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 12px;
}

.d31-related-object small,
.d31-related-object strong {
    display: block;
}

.d31-related-object small {
    color: var(--ui-text-soft);
    font-size: 6px;
}

.d31-related-object strong {
    margin-top: 2px;
    color: var(--ui-text);
    font-size: 8px;
}

.d31-related-object > i {
    color: var(--ui-text-soft);
    font-style: normal;
}

/* ---------------------------------------------------------------
   Attention center
   --------------------------------------------------------------- */

.d31-attention-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.d31-attention-total {
    display: grid;
    min-width: 82px;
    min-height: 82px;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 10px;
    border: 1px solid color-mix(
        in srgb,
        var(--ui-danger) 26%,
        var(--ui-border)
    );
    border-radius: 20px;
    background: var(--ui-danger-soft);
}

.d31-attention-total small {
    color: var(--ui-danger);
    font-size: 6px;
    font-weight: 800;
}

.d31-attention-total strong {
    color: var(--ui-danger);
    font-size: 26px;
    line-height: 1;
}

.d31-attention-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 18px;
}

.d31-attention-stat {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-height: 64px;
    padding: 9px;
    border: 1px solid var(--ui-border);
    border-radius: 12px;
    background: var(--ui-surface);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-attention-stat > span {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px;
    background: var(--ui-bg-subtle);
    color: var(--ui-text-muted);
    font-size: 13px;
    font-weight: 900;
}

.d31-attention-stat small,
.d31-attention-stat strong {
    display: block;
}

.d31-attention-stat small {
    color: var(--ui-text-muted);
    font-size: 6px;
}

.d31-attention-stat strong {
    margin-top: 3px;
    color: var(--ui-text);
    font-size: 15px;
}

.d31-attention-stat.danger > span {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.d31-attention-stat.danger strong {
    color: var(--ui-danger);
}

.d31-attention-stat.primary > span {
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
}

.d31-attention-stat.primary strong {
    color: var(--ui-primary);
}

.d31-attention-stat.warning > span {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.d31-attention-stat.warning strong {
    color: var(--ui-warning);
}

.d31-calm-panel {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 16px;
    border-color: color-mix(
        in srgb,
        var(--ui-success) 24%,
        var(--ui-border)
    ) !important;
    background: var(--ui-success-soft) !important;
}

.d31-calm-panel > span {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    border-radius: 50%;
    background: var(--ui-success);
    color: #fff;
    font-size: 18px;
    font-weight: 900;
}

.d31-calm-panel h2 {
    margin: 2px 0 4px;
    color: var(--ui-success) !important;
}

.d31-calm-panel p:last-child {
    margin: 0;
    color: var(--ui-text-muted);
    font-size: 8px;
    line-height: 1.5;
}

.d31-attention-section {
    display: grid;
    gap: 8px;
    margin-top: 20px;
    scroll-margin-top: 78px;
}

.d31-heading-link {
    color: var(--ui-primary);
    font-size: 8px;
    font-weight: 800;
    text-decoration: none;
}

.d31-attention-list {
    display: grid;
    gap: 6px;
}

.d31-attention-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 9px;
    border: 1px solid var(--ui-border);
    border-radius: 11px;
    background: var(--ui-surface);
    color: var(--ui-text);
    text-decoration: none;
}

.d31-attention-row:hover {
    border-color: var(--ui-border-strong);
    box-shadow: var(--ui-shadow-sm);
}

.d31-attention-icon {
    display: grid;
    width: 35px;
    height: 35px;
    place-items: center;
    border-radius: 10px;
    background: var(--ui-primary-soft);
    color: var(--ui-primary);
    font-size: 12px;
    font-weight: 900;
}

.d31-attention-row.danger .d31-attention-icon {
    background: var(--ui-danger-soft);
    color: var(--ui-danger);
}

.d31-attention-row.warning .d31-attention-icon {
    background: var(--ui-warning-soft);
    color: var(--ui-warning);
}

.d31-attention-copy {
    min-width: 0;
}

.d31-attention-copy strong,
.d31-attention-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.d31-attention-copy strong {
    color: var(--ui-text);
    font-size: 9px;
}

.d31-attention-copy small {
    margin-top: 3px;
    color: var(--ui-text-muted);
    font-size: 7px;
}

.d31-attention-row > i {
    color: var(--ui-text-soft);
    font-style: normal;
}

/* ---------------------------------------------------------------
   D2 workspace homepage refinement
   --------------------------------------------------------------- */

.d31-home-heading {
    position: relative;
    overflow: hidden;
    padding: 16px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-xl);
    background:
        linear-gradient(
            135deg,
            var(--ui-primary-soft),
            var(--ui-surface) 52%,
            var(--ui-surface)
        );
    box-shadow: var(--ui-shadow-sm);
}

.d31-home-heading::after {
    position: absolute;
    top: -70px;
    right: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: color-mix(
        in srgb,
        var(--ui-primary) 9%,
        transparent
    );
    content: "";
    pointer-events: none;
}

.d31-home-heading h1 {
    font-size: clamp(29px, 7vw, 42px);
    letter-spacing: -.035em;
}

.d31-home-heading .workspace-heading-actions {
    position: relative;
    z-index: 1;
}

/* ---------------------------------------------------------------
   Desktop
   --------------------------------------------------------------- */

@media (min-width: 650px) {
    .d31-task-summary {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .d31-filter-form {
        grid-template-columns:
            minmax(170px, 1.2fr)
            minmax(140px, .8fr)
            auto
            auto;
        align-items: end;
    }

    .d31-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .d31-form-wide {
        grid-column: 1 / -1;
    }

    .d31-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .d31-form-section.d31-form-wide
    .d31-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .d31-form-actions button {
        width: auto;
        min-width: 170px;
    }

    .d31-person-chip {
        display: flex;
    }

    .d31-detail-facts {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .d31-attention-summary {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 1040px) {
    .d31-page-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .d31-hero-action {
        justify-self: end;
    }

    .d31-control-panel {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
    }

    .d31-segmented-links {
        width: 260px;
    }

    .d31-detail-grid {
        grid-template-columns: minmax(0, 1.65fr) minmax(260px, .7fr);
        align-items: start;
    }

    .d31-task-context-card {
        position: sticky;
        top: 82px;
    }

    .d31-calendar-week {
        grid-template-columns: repeat(7, minmax(0, 1fr));
        align-items: stretch;
        gap: 6px;
    }

    .d31-calendar-day {
        min-width: 0;
    }

    .d31-calendar-day > header {
        min-height: 61px;
    }

    .d31-calendar-day > header {
        padding: 8px;
    }

    .d31-calendar-day > header h2 {
        font-size: 9px;
    }

    .d31-calendar-day > header > span {
        min-width: 24px;
        height: 24px;
        font-size: 7px;
    }

    .d31-event-stack {
        align-content: start;
        min-height: 310px;
        padding: 5px;
    }

    .d31-event-card {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 7px;
    }

    .d31-event-time {
        display: flex;
        align-items: baseline;
        gap: 4px;
    }

    .d31-event-body > strong {
        white-space: normal;
    }

    .d31-event-card > i {
        display: none;
    }

    .d31-event-meta {
        display: grid;
    }

    .d31-calendar-empty {
        min-height: 80px;
    }
}

@media (max-width: 430px) {
    .d31-attention-hero {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .d31-attention-total {
        min-width: 68px;
        min-height: 68px;
        border-radius: 16px;
    }

    .d31-attention-total small {
        display: none;
    }

    .d31-attention-total strong {
        font-size: 23px;
    }

    .d31-calendar-toolbar {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .d31-calendar-today {
        display: none;
    }
}
