/*
 * Contiplano theme on top of Lumo: indigo primary, teal accent, slate neutrals, system font.
 * Dark mode: the html element gets theme="dark" (see ThemeToggle), and the same tokens are redefined below.
 */

html {
    --lumo-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    --lumo-border-radius-s: 6px;
    --lumo-border-radius-m: 10px;
    --lumo-border-radius-l: 16px;

    --lumo-primary-color: #4f46e5;
    --lumo-primary-color-50pct: rgba(79, 70, 229, 0.5);
    --lumo-primary-color-10pct: rgba(79, 70, 229, 0.1);
    --lumo-primary-text-color: #4338ca;
    --lumo-primary-contrast-color: #fff;
    --lumo-success-color: #16a34a;
    --lumo-success-color-50pct: rgba(22, 163, 74, 0.5);
    --lumo-success-color-10pct: rgba(22, 163, 74, 0.1);
    --lumo-success-text-color: #15803d;
    --lumo-error-color: #dc2626;
    --lumo-error-color-50pct: rgba(220, 38, 38, 0.5);
    --lumo-error-color-10pct: rgba(220, 38, 38, 0.1);
    --lumo-error-text-color: #b91c1c;
    --lumo-warning-color: #d97706;
    --lumo-warning-color-10pct: rgba(217, 119, 6, 0.12);
    --lumo-warning-text-color: #b45309;
    --lumo-header-text-color: #0f172a;
    --lumo-body-text-color: #1e293b;
    --lumo-secondary-text-color: #64748b;
    --lumo-tertiary-text-color: #94a3b8;

    /* Contiplano tokens */
    --cp-accent: #0d9488;
    --cp-accent-soft: rgba(13, 148, 136, 0.12);
    --cp-page: #f8fafc;
    --cp-card: #ffffff;
    --cp-border: #e2e8f0;
    --cp-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
    --cp-gradient: linear-gradient(135deg, #4f46e5 0%, #0d9488 100%);
    --cp-violet: #7c3aed;
    --cp-violet-soft: rgba(124, 58, 237, 0.12);
    --cp-blue: #2563eb;
    --cp-blue-soft: rgba(37, 99, 235, 0.12);
    --cp-grey: #64748b;
    --cp-grey-soft: rgba(100, 116, 139, 0.12);

    background: var(--cp-page);
}

html[theme~="dark"] {
    --lumo-base-color: #1e293b;
    --lumo-primary-color: #6366f1;
    --lumo-primary-color-50pct: rgba(129, 140, 248, 0.5);
    --lumo-primary-color-10pct: rgba(129, 140, 248, 0.16);
    --lumo-primary-text-color: #a5b4fc;
    --lumo-success-color: #22c55e;
    --lumo-success-color-10pct: rgba(34, 197, 94, 0.16);
    --lumo-success-text-color: #4ade80;
    --lumo-error-color: #ef4444;
    --lumo-error-color-10pct: rgba(239, 68, 68, 0.16);
    --lumo-error-text-color: #fca5a5;
    --lumo-warning-color: #f59e0b;
    --lumo-warning-color-10pct: rgba(245, 158, 11, 0.16);
    --lumo-warning-text-color: #fcd34d;
    --lumo-header-text-color: #f1f5f9;
    --lumo-body-text-color: #e2e8f0;
    --lumo-secondary-text-color: #94a3b8;
    --lumo-tertiary-text-color: #64748b;

    --cp-accent: #2dd4bf;
    --cp-accent-soft: rgba(45, 212, 191, 0.14);
    --cp-page: #0f172a;
    --cp-card: #1e293b;
    --cp-border: #334155;
    --cp-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --cp-gradient: linear-gradient(135deg, #6366f1 0%, #14b8a6 100%);
    --cp-violet: #a78bfa;
    --cp-violet-soft: rgba(167, 139, 250, 0.16);
    --cp-blue: #60a5fa;
    --cp-blue-soft: rgba(96, 165, 250, 0.16);
    --cp-grey: #94a3b8;
    --cp-grey-soft: rgba(148, 163, 184, 0.14);
}

body {
    background: var(--cp-page);
    -webkit-font-smoothing: antialiased;
}

/* ---------- App frame ---------- */

vaadin-app-layout {
    --vaadin-app-layout-navbar-background: var(--cp-card);
    --vaadin-app-layout-drawer-background: var(--cp-card);
    background: var(--cp-page);
}

vaadin-app-layout::part(navbar) {
    border-bottom: 1px solid var(--cp-border);
    box-shadow: none;
}

vaadin-app-layout::part(drawer) {
    border-inline-end: 1px solid var(--cp-border);
}

.cp-header {
    width: 100%;
    padding-inline: var(--lumo-space-m);
    gap: var(--lumo-space-s);
}

.cp-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: var(--lumo-font-size-l);
    color: var(--lumo-header-text-color);
    letter-spacing: -0.01em;
}

/* The Orbit mark (Logo.java); colours from docs/DESIGN.md, following the app's theme toggle. */
.cp-logo {
    display: block;
    flex: none;
}

.cp-logo svg {
    display: block;
}

.cp-logo-ring {
    stroke: #4f46e5;
}

.cp-logo-dot {
    fill: #0d9488;
}

html[theme~="dark"] .cp-logo-ring {
    stroke: #818cf8;
}

html[theme~="dark"] .cp-logo-dot {
    fill: #2dd4bf;
}

.cp-workspace-switcher::part(container) {
    gap: 0;
}

.cp-workspace-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: var(--lumo-primary-color-10pct);
    color: var(--lumo-primary-text-color);
    font-weight: 600;
    font-size: var(--lumo-font-size-s);
}

.cp-workspace-pill vaadin-icon {
    width: 14px;
    height: 14px;
}

.cp-elsewhere {
    background: var(--cp-accent);
    color: #fff;
    border-radius: 999px;
    padding: 0 0.45rem;
    font-size: var(--lumo-font-size-xxs);
    font-weight: 700;
}

.cp-avatar-name {
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-s);
}

/* Side navigation */
.cp-nav {
    padding: var(--lumo-space-s);
    display: flex;
    flex-direction: column;
    min-height: 100%;
    box-sizing: border-box;
}

/* Who makes Contiplano: at the bottom of the menu and under the login card. */
.cp-credits {
    font-size: var(--lumo-font-size-xxs);
    line-height: 1.6;
    color: var(--lumo-tertiary-text-color);
}

.cp-credits a {
    color: var(--lumo-secondary-text-color);
    text-decoration: none;
}

.cp-credits a:hover {
    text-decoration: underline;
}

.cp-nav .cp-credits {
    margin-top: auto;
    padding: var(--lumo-space-l) var(--lumo-space-s) var(--lumo-space-xs);
    border-top: 1px solid var(--lumo-contrast-10pct);
}

.cp-login .cp-credits {
    margin-top: var(--lumo-space-l);
    text-align: center;
}

.cp-nav-section {
    margin: var(--lumo-space-m) var(--lumo-space-s) var(--lumo-space-xs);
    font-size: var(--lumo-font-size-xxs);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--lumo-tertiary-text-color);
}

vaadin-side-nav-item::part(content) {
    border-radius: var(--lumo-border-radius-m);
}

vaadin-side-nav-item[current]::part(content) {
    background: var(--lumo-primary-color-10pct);
    color: var(--lumo-primary-text-color);
    font-weight: 600;
}

vaadin-side-nav-item vaadin-icon[slot="prefix"] {
    color: var(--lumo-secondary-text-color);
    width: 18px;
    height: 18px;
}

vaadin-side-nav-item[current] vaadin-icon[slot="prefix"] {
    color: var(--lumo-primary-color);
}

/* ---------- Page building blocks ---------- */

.cp-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--lumo-space-l) var(--lumo-space-l) var(--lumo-space-xl);
    gap: var(--lumo-space-l);
}

.cp-page-header {
    width: 100%;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--lumo-space-m);
}

.cp-page-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--lumo-header-text-color);
}

.cp-page-subtitle {
    margin: 0.2rem 0 0;
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-s);
}

.cp-card {
    box-sizing: border-box;
    width: 100%;
    background: var(--cp-card);
    border: 1px solid var(--cp-border);
    border-radius: var(--lumo-border-radius-l);
    box-shadow: var(--cp-shadow);
    padding: var(--lumo-space-m) var(--lumo-space-l);
}

.cp-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 var(--lumo-space-s);
    font-size: var(--lumo-font-size-m);
    font-weight: 700;
    color: var(--lumo-header-text-color);
}

.cp-card-title vaadin-icon {
    width: 18px;
    height: 18px;
    color: var(--lumo-primary-color);
}

.cp-muted {
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-s);
}

.cp-empty {
    color: var(--lumo-secondary-text-color);
    text-align: center;
    padding: var(--lumo-space-l);
}

/* Grids sit inside cards without their own frame */
.cp-card vaadin-grid,
vaadin-grid.cp-grid {
    --vaadin-grid-cell-background: transparent;
    border: none;
    background: transparent;
}

vaadin-grid::part(header-cell) {
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

vaadin-grid::part(row):hover {
    cursor: pointer;
}

vaadin-grid::part(body-cell) {
    border-top-color: var(--cp-border);
}

/* My queue: the first row of each part of the queue (workspace time, Start at, at risk, by score, waiting) */
vaadin-grid::part(cp-section-start) {
    border-top: 2px solid var(--cp-border);
}

.cp-section-label {
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-xxs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* My queue: a bracket per part (Start at now, at risk, by score, waiting). Each row's cell draws its piece of the
   line, with a cap on the part's first and last row, so the pieces join into one large bracket. */
vaadin-grid::part(cp-bracket) {
    --cp-bracket-color: var(--cp-grey);
    --cp-bracket-line: linear-gradient(var(--cp-bracket-color), var(--cp-bracket-color));
    --cp-bracket-top: 0px;
    --cp-bracket-bottom: 0px;
    --cp-bracket-cap-top: 0px;
    --cp-bracket-cap-bottom: 0px;
    border-top-color: transparent;
    background-image: var(--cp-bracket-line),
        linear-gradient(var(--cp-bracket-color), var(--cp-bracket-color)),
        linear-gradient(var(--cp-bracket-color), var(--cp-bracket-color));
    background-repeat: no-repeat;
    background-size: 3px calc(100% - var(--cp-bracket-top) - var(--cp-bracket-bottom)),
        var(--cp-bracket-cap-top) 3px, var(--cp-bracket-cap-bottom) 3px;
    background-position: right 6px top var(--cp-bracket-top), right 0 top var(--cp-bracket-top),
        right 0 bottom var(--cp-bracket-bottom);
}

vaadin-grid::part(cp-bracket--first) {
    --cp-bracket-top: 6px;
    --cp-bracket-cap-top: 9px;
}

vaadin-grid::part(cp-bracket--last) {
    --cp-bracket-bottom: 6px;
    --cp-bracket-cap-bottom: 9px;
}

vaadin-grid::part(cp-bracket--start-at) {
    --cp-bracket-color: var(--cp-blue);
}

vaadin-grid::part(cp-bracket--at-risk) {
    --cp-bracket-color: var(--lumo-error-color);
}

vaadin-grid::part(cp-bracket--by-score) {
    --cp-bracket-color: var(--cp-accent);
}

vaadin-grid::part(cp-bracket--later) {
    --cp-bracket-line: repeating-linear-gradient(to bottom, var(--cp-bracket-color) 0 5px, transparent 5px 9px);
}

/* The note reads bottom to top beside the bracket's first row. */
.cp-bracket-note {
    display: block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    line-height: 1;
    margin-left: calc(var(--lumo-space-m) * -1 + 2px);
    font-size: var(--lumo-font-size-xxs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--lumo-secondary-text-color);
}

/* Buttons */
vaadin-button[theme~="primary"] {
    background: var(--lumo-primary-color);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

vaadin-button.cp-next {
    background: var(--cp-gradient);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
}

/* ---------- Chips ---------- */

.cp-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    font-size: var(--lumo-font-size-xs);
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    background: var(--cp-grey-soft);
    color: var(--cp-grey);
}

.cp-chip vaadin-icon {
    width: 12px;
    height: 12px;
}

.cp-chip--active { background: var(--lumo-success-color-10pct); color: var(--lumo-success-text-color); }
.cp-chip--on_hold { background: var(--lumo-warning-color-10pct); color: var(--lumo-warning-text-color); }
.cp-chip--todo { background: var(--lumo-primary-color-10pct); color: var(--lumo-primary-text-color); }
.cp-chip--in_review { background: var(--cp-violet-soft); color: var(--cp-violet); }
.cp-chip--done { background: var(--cp-blue-soft); color: var(--cp-blue); }
.cp-chip--cancelled { background: var(--cp-grey-soft); color: var(--cp-grey); text-decoration: line-through; }
.cp-chip--waiting { background: var(--cp-grey-soft); color: var(--cp-grey); }
.cp-chip--resting { background: var(--cp-accent-soft); color: var(--cp-accent); }
.cp-chip--empty { background: var(--cp-grey-soft); color: var(--cp-grey); }
.cp-chip--container { background: var(--cp-accent-soft); color: var(--cp-accent); }
.cp-chip--able { background: var(--lumo-success-color-10pct); color: var(--lumo-success-text-color); }
.cp-chip--via { background: var(--cp-grey-soft); color: var(--cp-grey); }

.cp-prio { min-width: 2.1rem; justify-content: center; }

/* ---------- Compact list cells ---------- */

.cp-icon-header {
    display: inline-flex;
}

.cp-icon-header vaadin-icon {
    width: 14px;
    height: 14px;
}

.cp-nowrap {
    white-space: nowrap;
}

/* One line, cut with "…"; the full text is on hover. */
.cp-ellipsis {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-title-row {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

/* Problems of a responsibility wrap instead of being cut off. */
/* My ownership: one line per row; the first problem is cut with "…", the full list shows on hover. */
.cp-problems {
    flex-wrap: nowrap;
    min-width: 0;
}

.cp-problems .cp-chip {
    min-width: 0;
}

.cp-problems .cp-chip > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-problems .cp-chip > vaadin-icon {
    flex: none;
}

.cp-problems .cp-chip:last-child:not(:first-child) {
    flex: none;
}

/* Short date chips, one under the other. */
.cp-dates--compact {
    flex-direction: column;
    align-items: flex-start;
}

/* An icon alone, the meaning on hover. */
.cp-chip--icon {
    padding: 0.3rem;
}

.cp-chip--icon > span:empty {
    display: none;
}

.cp-chip-lines {
    display: inline-flex;
    flex-direction: column;
}

.cp-chip-lines > span {
    white-space: nowrap;
}

.cp-chip--two-lines {
    border-radius: var(--lumo-border-radius-m);
    line-height: 1.25;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.cp-chip vaadin-icon[src] {
    width: 13px;
    height: 13px;
}

/* A person, a team or nobody as a small circle. */
.cp-avatar {
    --vaadin-avatar-size: 1.7rem;
    flex: none;
}

.cp-avatar--team,
.cp-avatar--nobody,
.cp-avatar--more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    font-size: var(--lumo-font-size-xxs);
    font-weight: 600;
}

.cp-avatar--team {
    background: var(--cp-accent-soft);
    color: var(--cp-accent);
}

.cp-avatar--team vaadin-icon {
    width: 14px;
    height: 14px;
}

.cp-avatar--nobody {
    border: 1.5px dashed var(--lumo-contrast-30pct);
}

.cp-avatar--more {
    background: var(--cp-grey-soft);
    color: var(--lumo-secondary-text-color);
    font-size: 0.7rem;
}

/* A container's assignees, overlapping. */
.cp-avatar-group {
    display: inline-flex;
    align-items: center;
}

.cp-avatar-group > .cp-avatar + .cp-avatar {
    margin-left: -0.25rem;
}

.cp-avatar-group > .cp-avatar {
    box-shadow: 0 0 0 2px var(--lumo-base-color);
}
.cp-prio--1 { background: var(--lumo-error-color-10pct); color: var(--lumo-error-text-color); }
.cp-prio--2 { background: var(--lumo-warning-color-10pct); color: var(--lumo-warning-text-color); }
.cp-prio--3 { background: var(--lumo-primary-color-10pct); color: var(--lumo-primary-text-color); }
.cp-prio--4 { background: var(--cp-accent-soft); color: var(--cp-accent); }
.cp-prio--5 { background: var(--cp-grey-soft); color: var(--cp-grey); }
.cp-prio--inherited { opacity: 0.7; font-style: italic; }

.cp-chip--late { background: var(--lumo-error-color-10pct); color: var(--lumo-error-text-color); }
/* Time report */
.cp-period {
    font-weight: 600;
    min-width: 14rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.cp-timesheet {
    font-variant-numeric: tabular-nums;
}

.cp-report-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: var(--lumo-space-m);
    margin-block: var(--lumo-space-m);
}

.cp-shares {
    display: flex;
    flex-direction: column;
    gap: var(--lumo-space-s);
}

.cp-share {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px var(--lumo-space-s);
    font-size: var(--lumo-font-size-s);
}

.cp-share-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-share-value {
    color: var(--lumo-secondary-text-color);
    font-variant-numeric: tabular-nums;
}

.cp-share-track {
    grid-column: 1 / -1;
    height: 6px;
    border-radius: 3px;
    background: var(--lumo-contrast-10pct);
}

.cp-share-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--cp-gradient);
}

/* Section titles inside a long dialog, like the recurring task dialog. */
.cp-dialog-section {
    display: block;
    margin: var(--lumo-space-m) 0 var(--lumo-space-xs);
    font-size: var(--lumo-font-size-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lumo-secondary-text-color);
}

.cp-preview {
    margin-top: var(--lumo-space-m);
    padding: var(--lumo-space-s) var(--lumo-space-m);
    border-radius: var(--lumo-border-radius-m);
    background: var(--lumo-primary-color-10pct);
    color: var(--lumo-primary-text-color);
}

/* Date chips in a list column may wrap inside themselves rather than run past the column. */
.cp-dates .cp-chip {
    white-space: normal;
}

.cp-chip--ok { background: var(--lumo-success-color-10pct); color: var(--lumo-success-text-color); }

/* ---------- My queue ---------- */

.cp-running {
    width: 100%;
    box-sizing: border-box;
    border-radius: var(--lumo-border-radius-l);
    padding: var(--lumo-space-m) var(--lumo-space-l);
    background: var(--cp-gradient);
    color: #fff;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.3);
    align-items: center;
    flex-wrap: wrap;
    gap: var(--lumo-space-m);
}

.cp-running .cp-running-title {
    font-size: var(--lumo-font-size-l);
    font-weight: 700;
}

.cp-running .cp-running-meta {
    opacity: 0.85;
    font-size: var(--lumo-font-size-s);
}

.cp-running vaadin-button {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.cp-running vaadin-button[theme~="primary"] {
    background: #fff;
    color: #4338ca;
    box-shadow: none;
}

.cp-running .cp-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #a7f3d0;
    box-shadow: 0 0 0 0 rgba(167, 243, 208, 0.7);
    animation: cp-pulse 1.8s infinite;
}

@keyframes cp-pulse {
    0% { box-shadow: 0 0 0 0 rgba(167, 243, 208, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(167, 243, 208, 0); }
    100% { box-shadow: 0 0 0 0 rgba(167, 243, 208, 0); }
}

.cp-idle {
    width: 100%;
    box-sizing: border-box;
    border: 2px dashed var(--cp-border);
    border-radius: var(--lumo-border-radius-l);
    padding: var(--lumo-space-m) var(--lumo-space-l);
    color: var(--lumo-secondary-text-color);
    align-items: center;
    gap: var(--lumo-space-s);
}

.cp-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: var(--cp-card);
    border: 1px solid var(--cp-border);
    font-size: var(--lumo-font-size-s);
    color: var(--lumo-secondary-text-color);
}

.cp-stat vaadin-icon {
    width: 14px;
    height: 14px;
    color: var(--cp-accent);
}

/* Another tenant's (or shared) time right now: its tasks are in the queue too. */
.cp-stat--other {
    background: var(--lumo-primary-color-10pct);
    border-color: transparent;
    color: var(--lumo-primary-text-color);
    font-weight: 600;
}

.cp-attention-row {
    width: 100%;
    align-items: center;
    padding: 0.35rem 0;
    border-top: 1px solid var(--cp-border);
}

.cp-attention-row:first-of-type {
    border-top: none;
}

/* ---------- Task detail ---------- */

.cp-hero {
    gap: var(--lumo-space-s);
}

.cp-hero h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 750;
    letter-spacing: -0.02em;
    color: var(--lumo-header-text-color);
}

.cp-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.cp-breadcrumb {
    font-size: var(--lumo-font-size-s);
    color: var(--lumo-secondary-text-color);
    gap: 0.35rem;
    flex-wrap: wrap;
}

.cp-breadcrumb a {
    color: var(--lumo-primary-text-color);
    text-decoration: none;
}

.cp-facts vaadin-form-item::part(label) {
    color: var(--lumo-secondary-text-color);
    font-size: var(--lumo-font-size-s);
}

.cp-description-empty {
    color: var(--lumo-secondary-text-color);
    margin: 0;
}

/* A description written in Markdown. */
.cp-markdown {
    display: block;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.cp-markdown > :first-child {
    margin-top: 0;
}

.cp-markdown > :last-child {
    margin-bottom: 0;
}

.cp-markdown h1,
.cp-markdown h2,
.cp-markdown h3 {
    margin: 0.8em 0 0.4em;
    line-height: 1.3;
}

.cp-markdown h1 { font-size: var(--lumo-font-size-xl); }
.cp-markdown h2 { font-size: var(--lumo-font-size-l); }
.cp-markdown h3 { font-size: var(--lumo-font-size-m); }

.cp-markdown p,
.cp-markdown ul,
.cp-markdown ol,
.cp-markdown pre,
.cp-markdown blockquote {
    margin: 0 0 0.6em;
}

.cp-markdown a {
    color: var(--lumo-primary-text-color);
}

.cp-markdown code {
    font-family: var(--lumo-font-family-monospace, monospace);
    font-size: 0.9em;
    background: var(--lumo-contrast-5pct);
    border-radius: var(--lumo-border-radius-s);
    padding: 0.1em 0.3em;
}

.cp-markdown pre {
    background: var(--lumo-contrast-5pct);
    border-radius: var(--lumo-border-radius-m);
    padding: 0.6em 0.8em;
    overflow-x: auto;
}

.cp-markdown pre code {
    background: none;
    padding: 0;
    color: var(--lumo-body-text-color);
}

.cp-markdown--checkable input[type="checkbox"] {
    cursor: pointer;
}

/* A checklist: the boxes in place of the bullets, aligned with the text. */
.cp-markdown ul:has(> li > input[type="checkbox"]) {
    padding-left: 0;
}

.cp-markdown li:has(> input[type="checkbox"]) {
    list-style: none;
}

.cp-markdown input[type="checkbox"] {
    margin: 0 0.4em 0 0;
    vertical-align: middle;
}

.cp-markdown blockquote {
    border-left: 3px solid var(--lumo-contrast-20pct);
    padding-left: 0.8em;
    color: var(--lumo-secondary-text-color);
}

/* A formatted description edited in place: pencil top right, a soft background on hover instead of underlines. */
.cp-inline:has(> .cp-markdown) {
    align-items: flex-start;
}

.cp-inline > .cp-markdown {
    flex: 1;
}

/* Doubled class: wins over the dotted underline of other inline values, defined later in this file. */
.cp-inline:not(.cp-inline--editing):hover > .cp-markdown.cp-markdown {
    text-decoration: none;
    background: var(--lumo-contrast-5pct);
    border-radius: var(--lumo-border-radius-m);
    box-shadow: 0 0 0 0.4em var(--lumo-contrast-5pct);
}

.cp-markdown-preview {
    border: 1px dashed var(--lumo-contrast-20pct);
    border-radius: var(--lumo-border-radius-m);
    padding: 0.6em 0.8em;
    margin: 0.4em 0;
}

/* ---------- Timeline ---------- */

.cp-bar {
    position: absolute;
    top: 0.2em;
    height: 0.8em;
    border-radius: 999px;
    background: var(--cp-gradient);
}

.cp-bar--late {
    background: linear-gradient(135deg, #f87171, #dc2626);
}

.cp-bar--open {
    opacity: 0.5;
}

.cp-marker {
    position: absolute;
    top: 0;
    height: 1.2em;
    width: 2px;
    background: var(--lumo-contrast-50pct);
}

.cp-marker--late {
    background: var(--lumo-error-color);
}

/* From or At: work does not start before it. */
.cp-marker--start {
    width: 0;
    background: none;
    border-left: 2px dotted var(--lumo-primary-color);
}

/* ---------- Login ---------- */

.cp-login {
    min-height: 100vh;
    background: radial-gradient(circle at 20% 10%, rgba(79, 70, 229, 0.25), transparent 45%),
        radial-gradient(circle at 80% 90%, rgba(13, 148, 136, 0.25), transparent 45%), var(--cp-page);
}

.cp-login vaadin-login-form-wrapper {
    border-radius: var(--lumo-border-radius-l);
    box-shadow: var(--cp-shadow);
}

/* Review and check-in cards side by side, wrapping on narrow screens */
.cp-attention {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: var(--lumo-space-l);
}

.cp-attention:empty {
    display: none;
}

.cp-attention > .cp-card {
    flex: 1 1 22rem;
    width: auto;
}

/* Tables, forms and expandable sections placed directly on a page are framed as cards */
.cp-page > vaadin-grid,
.cp-page > vaadin-tree-grid,
.cp-page > vaadin-form-layout,
.cp-page > vaadin-details,
.cp-page > vaadin-vertical-layout > vaadin-details,
.cp-page vaadin-details.cp-card {
    box-sizing: border-box;
    width: 100%;
    background: var(--cp-card);
    border: 1px solid var(--cp-border);
    border-radius: var(--lumo-border-radius-l);
    box-shadow: var(--cp-shadow);
}

.cp-page > vaadin-grid,
.cp-page > vaadin-tree-grid {
    padding: var(--lumo-space-xs) var(--lumo-space-m);
}

.cp-page > vaadin-form-layout,
.cp-page > vaadin-details,
.cp-page > vaadin-vertical-layout > vaadin-details {
    padding: var(--lumo-space-m) var(--lumo-space-l);
}

.cp-page > vaadin-vertical-layout.cp-card,
.cp-page vaadin-vertical-layout.cp-card {
    padding: var(--lumo-space-m) var(--lumo-space-l);
}

.cp-page > vaadin-horizontal-layout:not(.cp-page-header):not(.cp-running):not(.cp-idle) {
    flex-wrap: wrap;
}

/* Chips inside grid cells may wrap onto several lines */
vaadin-grid-cell-content .cp-chips {
    white-space: normal;
}

.cp-login-card {
    border-radius: var(--lumo-border-radius-l);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
    border: 1px solid var(--cp-border);
    background: var(--cp-card);
}

/* ---------- Quick add ---------- */

.cp-quickadd {
    box-sizing: border-box;
    width: 100%;
    background: var(--cp-card);
    border: 1px solid var(--cp-border);
    border-radius: var(--lumo-border-radius-l);
    box-shadow: var(--cp-shadow);
    padding: var(--lumo-space-s) var(--lumo-space-m) var(--lumo-space-s);
}

.cp-quickadd vaadin-text-field {
    --vaadin-input-field-background: transparent;
    font-size: var(--lumo-font-size-l);
    --lumo-text-field-size: 3rem;
}

.cp-quickadd vaadin-text-field::part(input-field) {
    background: transparent;
    box-shadow: none;
}

.cp-quickadd vaadin-text-field vaadin-icon[slot="prefix"] {
    color: var(--lumo-primary-color);
    width: 22px;
    height: 22px;
}

.cp-quickadd-hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    min-height: 1.6rem;
    padding: 0 var(--lumo-space-s) var(--lumo-space-xs);
}

/* ---------- Task tree ---------- */

.cp-drop-zone {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: var(--lumo-space-s);
    padding: var(--lumo-space-s) var(--lumo-space-m);
    border: 2px dashed var(--lumo-primary-color-50pct);
    border-radius: var(--lumo-border-radius-m);
    background: var(--lumo-primary-color-10pct);
    color: var(--lumo-primary-text-color);
    font-weight: 600;
}

vaadin-grid::part(dragover-on-top-row-cell) {
    background: var(--lumo-primary-color-10pct);
}

/* Recommended assignees in the assign dialog. */
.cp-recommended {
    border: 1px solid var(--lumo-contrast-10pct);
    border-radius: var(--lumo-border-radius-l);
    padding: var(--lumo-space-s) var(--lumo-space-m);
    margin-bottom: var(--lumo-space-m);
}
.cp-recommended-row {
    padding: var(--lumo-space-xs) 0;
    border-top: 1px solid var(--lumo-contrast-5pct);
}

/* The running task in the header. */
.cp-runbar {
    min-width: 0;
    gap: var(--lumo-space-s);
}
.cp-runbar-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* When the header is crowded, the title and its line below end in "…" instead of running over the buttons. */
    overflow: hidden;
    line-height: 1.2;
}
.cp-runbar-title {
    font-weight: 600;
    color: var(--lumo-body-text-color);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 28rem;
}
.cp-runbar-title:hover {
    text-decoration: underline;
}
.cp-runbar-meta {
    font-size: var(--lumo-font-size-xs);
    color: var(--lumo-secondary-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cp-runbar .cp-pulse {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--lumo-success-color);
    animation: cp-pulse-green 1.8s infinite;
}
@keyframes cp-pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.cp-runbar-idle-icon {
    color: var(--lumo-secondary-text-color);
    display: inline-flex;
}
.cp-runbar vaadin-button {
    flex: none;
}
.cp-runbar .cp-split-button {
    flex: none;
}
.cp-runbar-spacer {
    flex: 1 1 0;
    min-width: var(--lumo-space-s);
}
.cp-header-divider {
    flex: none;
    width: 1px;
    height: 1.75rem;
    margin-inline: var(--lumo-space-s);
    background: var(--lumo-contrast-20pct);
}
/* The tenant switcher and the user menu never collapse into an overflow menu; the running task shrinks. */
.cp-workspace-switcher,
.cp-user-menu {
    flex: none;
}

/* Narrow screens: the title shrinks, buttons show only their icons, the tenant pill only its name. */
@media (max-width: 760px) {
    .cp-runbar-meta,
    .cp-avatar-name {
        display: none;
    }
    .cp-runbar vaadin-button::part(label) {
        display: none;
    }
    .cp-runbar vaadin-button {
        min-width: var(--lumo-button-size);
        padding: 0 var(--lumo-space-xs);
    }
    .cp-runbar vaadin-button::part(prefix) {
        margin: 0;
    }
    .cp-header {
        overflow: hidden;
    }
    .cp-header-divider {
        margin-inline: var(--lumo-space-xs);
    }
    .cp-runbar-title {
        max-width: 9rem;
    }
    /* The title gives way first, so Pause and Done never spill over the theme button. */
    .cp-runbar-text {
        min-width: 0;
        flex: 1 1 auto;
    }
    .cp-runbar-spacer {
        min-width: 0;
    }
    .cp-runbar .cp-runbar-next,
    .cp-workspace-pill > span:not(.cp-elsewhere) {
        display: none;
    }
    /* Pause until… stays on the task page; the header keeps the plain Pause icon. */
    .cp-runbar .cp-split-button > vaadin-button:last-child {
        display: none;
    }
    .cp-runbar .cp-split-button > vaadin-button:first-child {
        border-radius: var(--lumo-border-radius-m);
        margin-inline-end: 0;
    }
    .cp-header {
        padding-inline: var(--lumo-space-xs);
        gap: var(--lumo-space-xs);
    }
}

/* "Your account is ready" above the login form. */
.cp-registered {
    margin: 0 0 var(--lumo-space-s);
    padding: var(--lumo-space-s) var(--lumo-space-m);
    border-radius: var(--lumo-border-radius-m);
    background: var(--lumo-success-color-10pct);
    color: var(--lumo-success-text-color);
    font-size: var(--lumo-font-size-s);
    /* The login form sets the card's width; a long email address wraps instead of widening the card. */
    box-sizing: border-box;
    width: 0;
    min-width: 100%;
    overflow-wrap: anywhere;
}

/* Values edited in place: a pencil and a light underline on hover show what can be clicked. */
.cp-inline {
    display: flex;
    align-items: center;
    gap: var(--lumo-space-s);
    cursor: text;
    border-radius: var(--lumo-border-radius-m);
}

.cp-inline > :first-child {
    margin: 0;
    min-width: 0;
}

.cp-inline:not(.cp-inline--editing):hover > :first-child {
    text-decoration: underline dotted var(--lumo-contrast-40pct);
    text-underline-offset: 0.25em;
}

.cp-inline--editing {
    display: block;
    cursor: auto;
}

.cp-inline-pencil {
    width: 14px;
    height: 14px;
    flex: none;
    color: var(--lumo-contrast-40pct);
    opacity: 0;
    transition: opacity 0.15s;
}

.cp-inline:hover .cp-inline-pencil {
    opacity: 1;
}

@media (hover: none) {
    .cp-inline-pencil {
        opacity: 0.6;
    }
}

.cp-inline-chip {
    display: inline-flex;
    cursor: pointer;
    border-radius: 999px;
}

.cp-inline-chip:hover > * {
    box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
    border-radius: 999px;
}

.cp-inline-popover {
    display: flex;
    flex-direction: column;
    gap: var(--lumo-space-s);
    padding: var(--lumo-space-s);
    max-width: min(34rem, 90vw);
}

.cp-inline--text {
    display: inline-flex;
    cursor: pointer;
}

.cp-inline--text:hover > :first-child {
    text-decoration: underline dotted var(--lumo-contrast-40pct);
    text-underline-offset: 0.25em;
}

/* A button with a dropdown arrow joined to its right side. */
.cp-split-button {
    display: inline-flex;
}

.cp-split-button > vaadin-button:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-inline-end: 1px;
}

.cp-split-button > vaadin-button:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-width: var(--lumo-size-m);
    padding: 0 var(--lumo-space-xs);
}

/* "Task" header of All tasks with Expand all and Collapse all. */
.cp-tree-header {
    gap: 0.25rem;
}

.cp-tree-header vaadin-button {
    color: var(--lumo-secondary-text-color);
    margin: 0;
}

.cp-tree-header vaadin-button:hover {
    color: var(--lumo-primary-text-color);
}

.cp-tree-header vaadin-icon {
    width: 15px;
    height: 15px;
}

/* "Send feedback" above the credits at the bottom of the menu. */
.cp-credits .cp-feedback-link {
    margin: 0 0 var(--lumo-space-xs) calc(var(--lumo-space-xs) * -1);
    font-size: var(--lumo-font-size-xs);
    color: var(--lumo-secondary-text-color);
}

.cp-credits .cp-feedback-link:hover {
    color: var(--lumo-primary-text-color);
}

/* Usage page (global admins). */
.cp-usage-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 11rem;
    padding: var(--lumo-space-m);
    border-radius: var(--lumo-border-radius-l);
    background: var(--lumo-base-color);
    border: 1px solid var(--lumo-contrast-10pct);
    font-size: var(--lumo-font-size-s);
    color: var(--lumo-secondary-text-color);
}

.cp-usage-number {
    font-size: var(--lumo-font-size-xxl);
    font-weight: 700;
    color: var(--lumo-body-text-color);
}

.cp-usage-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 8rem;
    padding: var(--lumo-space-s);
    border-radius: var(--lumo-border-radius-l);
    background: var(--lumo-base-color);
    border: 1px solid var(--lumo-contrast-10pct);
}

.cp-usage-bar {
    flex: 1;
    min-width: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--cp-accent, var(--lumo-primary-color));
}

.cp-usage h3 {
    margin: var(--lumo-space-l) 0 var(--lumo-space-s);
}

/* ---------- Search (Ctrl+K) ---------- */

.cp-search-results {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: var(--lumo-space-s);
    max-height: min(60vh, 32rem);
    overflow-y: auto;
}

.cp-search-row {
    padding: var(--lumo-space-s) var(--lumo-space-m);
    border-radius: var(--lumo-border-radius-m);
    cursor: pointer;
}

.cp-search-row:hover,
.cp-search-row.cp-selected {
    background: var(--lumo-primary-color-10pct);
}

.cp-search-title {
    display: flex;
    align-items: center;
    gap: var(--lumo-space-xs);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.cp-search-title vaadin-icon {
    width: var(--lumo-icon-size-s);
    height: var(--lumo-icon-size-s);
    color: var(--lumo-secondary-text-color);
    flex: none;
}

.cp-search-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--lumo-space-s);
    margin-top: 2px;
    font-size: var(--lumo-font-size-s);
    color: var(--lumo-secondary-text-color);
}

.cp-search-snippet {
    margin-top: 2px;
    font-size: var(--lumo-font-size-s);
    color: var(--lumo-secondary-text-color);
}

.cp-search-row mark {
    background: var(--lumo-warning-color-50pct, rgba(255, 196, 0, 0.45));
    color: inherit;
    border-radius: 2px;
}

.cp-search-group {
    margin-top: var(--lumo-space-s);
    padding: 0 var(--lumo-space-m);
    font-size: var(--lumo-font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lumo-secondary-text-color);
}

.cp-search-footer {
    margin-top: var(--lumo-space-s);
    font-size: var(--lumo-font-size-s);
}

.cp-search-footer:empty {
    display: none;
}

/* All tasks: the tree scrolls on its own, so only the rows in view are built. Once scrolled to, it fills the window. */
.cp-tree-grid {
    height: max(24rem, calc(100dvh - 9rem));
}

/*
 * All tasks, My ownership and Inbox fill the window exactly: the page itself does not scroll, the tree (or table)
 * takes the height left under the title, quick add and filters, and only it scrolls. One scrollbar, and the filters
 * stay in view.
 */
@media (min-width: 761px) {
    .cp-fill-page {
        height: calc(100dvh - var(--vaadin-app-layout-navbar-offset-size, 3.5rem));
        overflow: hidden;
        padding-bottom: var(--lumo-space-l);
    }

    .cp-fill-page > * {
        flex: none;
    }

    .cp-fill-page > .cp-tree-card {
        flex: 1 1 0;
        min-height: 12rem;
        display: flex;
        flex-direction: column;
    }

    .cp-fill-page .cp-tree-card > vaadin-grid {
        flex: 1 1 0;
        min-height: 0;
        height: auto;
    }
}

/*
 * Maximize (the tree header's button, see AppShell): the page covers the whole window, side menu and header
 * included, without its title and quick add; the filters stay. Also on a phone.
 */
.cp-fill-page.cp-maximized {
    position: fixed;
    inset: 0;
    z-index: 100;
    max-width: none;
    width: auto;
    height: auto;
    margin: 0;
    overflow: hidden;
    padding: var(--lumo-space-s) var(--lumo-space-m) var(--lumo-space-m);
    background: var(--cp-page);
}

.cp-fill-page.cp-maximized > .cp-page-header,
.cp-fill-page.cp-maximized > .cp-quickadd {
    display: none;
}

.cp-fill-page.cp-maximized > * {
    flex: none;
}

.cp-fill-page.cp-maximized > .cp-tree-card {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cp-fill-page.cp-maximized .cp-tree-card > vaadin-grid {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
}

/*
 * The Maximize button sits in the tree card's top right corner, over the end of the header row (the empty header of
 * the row menu column in All tasks), left of where the scrollbar runs.
 */
.cp-tree-card {
    position: relative;
}

.cp-tree-card > .cp-maximize {
    position: absolute;
    top: calc(var(--lumo-space-m) + 0.55rem);
    right: calc(var(--lumo-space-l) + 1.1rem);
    z-index: 2;
    margin: 0;
    color: var(--lumo-secondary-text-color);
}

.cp-tree-card > .cp-maximize vaadin-icon {
    width: var(--lumo-icon-size-s);
    height: var(--lumo-icon-size-s);
}

.cp-tree-card > .cp-maximize:hover {
    color: var(--lumo-primary-color);
}

.cp-maximize-off,
.cp-maximized .cp-maximize-on {
    display: none;
}

.cp-maximized .cp-maximize-off {
    display: inline-flex;
}

/* Inbox: unread notifications stand out. */
.cp-inbox-grid::part(unread-row) {
    font-weight: 600;
}

.cp-inbox-grid .cp-unread-dot {
    color: var(--lumo-primary-color);
}

/* Rows scroll under the header, so it needs a background of its own. */
.cp-tree-grid::part(header-cell),
.cp-inbox-grid::part(header-cell) {
    background: var(--cp-card);
}

@media (max-width: 760px) {
    .cp-tree-grid {
        height: max(18rem, calc(100dvh - 7rem));
    }
}

/* The chips of a create dialog (type, priority, estimate, assignee, date), each opening a menu or popover. */
.cp-dialog-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--lumo-space-s);
    margin: var(--lumo-space-xs) 0;
}

/* Keyboard shortcuts dialog: keys on the left, what they do on the right. */
.cp-shortcuts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--lumo-space-s) var(--lumo-space-m);
    align-items: baseline;
}

.cp-shortcut-keys {
    font-family: var(--lumo-font-family-monospace, monospace);
    font-size: var(--lumo-font-size-s);
    white-space: nowrap;
    padding: 2px var(--lumo-space-xs);
    border-radius: var(--lumo-border-radius-s);
    background: var(--lumo-contrast-10pct);
}

/* The list of quick-add codes shows while typing in the line; otherwise the chips are enough, and lists get room. */
.cp-quickadd:not(:focus-within) .cp-quickadd-help,
.cp-quickadd.cp-quickadd--quiet .cp-quickadd-help {
    display: none;
}

/* While a global admin views the app as someone else: whose app it is, and the way back. */
/* The shared demo account: a badge that explains the demo (DemoControls). */
.cp-demo-badge {
    background: var(--cp-accent-soft);
    color: var(--cp-accent);
    font-weight: 600;
    flex-shrink: 0;
}
@media (max-width: 760px) {
    .cp-demo-badge::part(label) {
        display: none;
    }
}

/* "Try the demo" under the login form. */
.cp-demo-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--lumo-space-xs);
    max-width: 22rem;
    text-align: center;
}

.cp-impersonation {
    background: var(--lumo-error-color);
    color: var(--lumo-error-contrast-color, #fff);
    font-weight: 600;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}
/* The badge already names the person, so the name next to the avatar goes, leaving room for the running task. */
.cp-header:has(.cp-impersonation) .cp-avatar-name {
    display: none;
}
/* Narrow screens: only the eye; the tooltip still names the person. */
@media (max-width: 760px) {
    .cp-impersonation::part(label) {
        display: none;
    }
    .cp-impersonation {
        min-width: var(--lumo-button-size);
        padding: 0 var(--lumo-space-xs);
    }
    .cp-impersonation::part(prefix) {
        margin: 0;
    }
}
