/* Projects page: views, stage tags, progress bars, cards, comparison, summary pop-up, form sections */
.pj-muted {
    color: var(--text-muted, #64748b);
    font-size: 0.85em;
}
.pj-warn {
    color: #b45309;
}
.pj-up {
    color: #16a34a;
    font-weight: 600;
}
.pj-down {
    color: #dc2626;
    font-weight: 600;
}
.pj-name {
    font-weight: 600;
    color: var(--primary-600, #2563eb);
    text-decoration: none;
}
.pj-name:hover {
    text-decoration: underline;
}
.pj-viewbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    margin: 0 0 0.75rem;
}
.pj-seg {
    display: inline-flex;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
}
.pj-seg button {
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #475569);
    border: 0;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font: inherit;
}
.pj-seg button + button {
    border-left: 1px solid var(--border-light, #e2e8f0);
}
.pj-seg button.active {
    background: var(--primary-600, #2563eb);
    color: #fff;
}
.pj-check {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
}
.pj-stage {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.pj-st-off {
    background: #ede9fe;
    color: #6d28d9;
}
.pj-st-uc {
    background: #fef3c7;
    color: #b45309;
}
.pj-st-ho {
    background: #cffafe;
    color: #0e7490;
}
.pj-st-done {
    background: #dcfce7;
    color: #15803d;
}
.pj-bar {
    display: inline-block;
    width: 80px;
    height: 7px;
    border-radius: 4px;
    background: var(--border-light, #e2e8f0);
    overflow: hidden;
    vertical-align: middle;
}
.pj-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #22c55e);
}
.pj-pct {
    font-size: 0.8rem;
    margin-inline-start: 0.35rem;
}
.pj-mobile-bar {
    display: none;
}
.pj-empty td {
    opacity: 0.7;
}
.pj-empty-tag {
    margin-inline-start: 0.4rem;
    font-size: 0.7rem;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 6px;
    padding: 0.05rem 0.4rem;
}

/* cards */
.pj-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1rem;
}
.pj-cards[hidden],
#pj-compare[hidden],
.table-container[hidden] {
    display: none;
}
.pj-card {
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 14px;
    background: var(--bg-card, #fff);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.pj-card-img {
    height: 130px;
    background: linear-gradient(135deg, #6366f1, #06b6d4) center/cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2.2rem;
    position: relative;
    cursor: pointer;
}
.pj-card-stage {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
}
.pj-card-body {
    padding: 0.8rem 0.9rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.pj-card-built {
    display: flex;
    align-items: center;
}
.pj-card-built .pj-bar {
    flex: 1;
    width: auto;
}
.pj-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.8rem;
}
.pj-card-grid span {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted, #64748b);
}
.pj-card-grid b {
    font-size: 0.9rem;
}
.pj-card-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.3rem;
}
.pj-links a {
    margin-inline-end: 0.5rem;
    color: var(--text-secondary, #475569);
}

/* comparison */
.pj-cmp-chart {
    max-width: 760px;
    margin: 0.5rem 0 1rem;
}
.pj-sortable {
    cursor: pointer;
    white-space: nowrap;
}
.pj-best td {
    background: rgba(34, 197, 94, 0.08);
}

/* summary pop-up */
.pj-modal {
    max-width: 920px;
    width: 96vw;
}
.pj-d-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin-bottom: 0.75rem;
}
.pj-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
}
.pj-kpi {
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 10px;
    padding: 0.55rem 0.7rem;
    display: flex;
    flex-direction: column;
    background: var(--bg-card, #fff);
}
.pj-kpi span {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
}
.pj-kpi b {
    font-size: 1.05rem;
}
.pj-kpi small {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
}
.pj-h {
    margin: 1.1rem 0 0.4rem;
    font-size: 0.95rem;
}
.pj-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}
.pj-dl {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.pj-dl td {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
}
.pj-dl td:first-child {
    color: var(--text-muted, #64748b);
    padding-inline-end: 0.8rem;
}
.pj-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}
.pj-tl {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0;
}
.pj-tl li {
    flex: 1 1 130px;
    position: relative;
    padding-top: 1.1rem;
    display: flex;
    flex-direction: column;
    font-size: 0.82rem;
}
.pj-tl li::before {
    content: '';
    position: absolute;
    top: 5px;
    inset-inline: 0;
    height: 2px;
    background: var(--border-light, #cbd5e1);
}
.pj-tl li i {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bg-card, #fff);
    border: 2px solid #94a3b8;
}
.pj-tl .pj-tl-past i {
    background: #22c55e;
    border-color: #22c55e;
}
.pj-tl .pj-tl-today i {
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}
.pj-tl .pj-tl-today b {
    color: #dc2626;
}
.pj-tl span {
    color: var(--text-muted, #64748b);
}
.pj-tag {
    display: inline-block;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 6px;
    padding: 0.1rem 0.5rem;
    font-size: 0.78rem;
    margin: 0 0.2rem 0.2rem 0;
}
.pj-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.6rem;
}
.pj-fig {
    margin: 0;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
}
.pj-fig img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    background: #f1f5f9;
}
.pj-fig figcaption {
    font-size: 0.72rem;
    padding: 0.3rem 0.4rem;
    position: relative;
}
.pj-linkimg {
    height: 110px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    background: #f1f5f9;
    color: #475569;
    text-decoration: none;
    font-size: 0.8rem;
}
.pj-x {
    position: absolute;
    top: 2px;
    inset-inline-end: 2px;
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #94a3b8;
}
.pj-addmedia {
    display: grid;
    grid-template-columns: 130px 1.2fr 1.2fr 1fr auto;
    gap: 0.4rem;
    margin-top: 0.6rem;
}
.pj-foot {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* form sections */
.pj-more {
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 10px;
    padding: 0.4rem 0.8rem;
    margin-top: 0.6rem;
}
.pj-more summary {
    cursor: pointer;
    font-weight: 600;
    padding: 0.3rem 0;
}
.pj-amen {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.3rem 0.8rem;
    margin: 0.3rem 0 0.6rem;
}

/* mobile: compact list, name + thin build bar + stage */
@media (max-width: 768px) {
    /* compact list: project, thin build bar, stage, actions (the rest is in the summary pop-up) */
    #projects-table td.pj-hide-m:not([data-label='Built']),
    #projects-table thead th:nth-child(2),
    #projects-table thead th:nth-child(3),
    #projects-table thead th:nth-child(4),
    #projects-table thead th:nth-child(6) {
        display: none;
    }
    #projects-table td[data-label='Built'] .pj-bar {
        width: 100%;
        max-width: 160px;
        height: 4px;
    }
    .pj-two {
        grid-template-columns: 1fr;
    }
    .pj-addmedia {
        grid-template-columns: 1fr;
    }
    .pj-cards {
        grid-template-columns: 1fr;
    }
}

/* project Documents + History (project-library.js) */
.pl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}
.pl-chip {
    border: 1px solid var(--border-light, #e2e8f0);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #475569);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.78rem;
    cursor: pointer;
}
.pl-chip b {
    font-weight: 600;
    margin-left: 0.2rem;
}
.pl-chip.on {
    background: var(--primary-600, #2563eb);
    border-color: var(--primary-600, #2563eb);
    color: #fff;
}
.pl-search {
    max-width: 320px;
    margin-bottom: 0.5rem;
}
.pl-tablewrap {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
}
.pl-table td {
    vertical-align: top;
}
.pl-table .pl-date {
    white-space: nowrap;
    color: var(--text-muted, #64748b);
    font-size: 0.8rem;
    width: 1%;
}
.pl-name {
    word-break: break-word;
}
.pl-name i {
    color: var(--primary-600, #2563eb);
    margin-right: 0.3rem;
}
.pl-table small {
    display: block;
}
.pl-act {
    white-space: nowrap;
    text-align: right;
    width: 1%;
}
.pl-vis {
    border: 1px solid var(--border-light, #e2e8f0);
    background: transparent;
    border-radius: 6px;
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    cursor: pointer;
    color: var(--text-secondary, #475569);
}
.pl-vis.owners {
    color: #15803d;
    border-color: #86efac;
}
.pl-vis.admin {
    color: #b45309;
    border-color: #fcd34d;
}
.pl-vis:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}
.pl-hint {
    font-size: 0.78rem;
    margin-top: 0.4rem;
}
.pl-future-toggle {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary, #475569);
}
.pl-hist {
    list-style: none;
    margin: 0;
    padding: 0 0 0 0.2rem;
    max-height: 520px;
    overflow: auto;
    border-left: 2px solid var(--border-light, #e2e8f0);
}
.pl-month {
    font-weight: 600;
    font-size: 0.8rem;
    margin: 0.7rem 0 0.25rem 0.6rem;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.pl-ev {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    padding: 0.3rem 0.4rem 0.3rem 0.6rem;
    font-size: 0.85rem;
}
.pl-ev > i {
    width: 1.1rem;
    text-align: center;
    margin-top: 0.15rem;
    color: var(--primary-600, #2563eb);
}
.pl-ev small {
    display: block;
}
.pl-evdate {
    color: var(--text-muted, #64748b);
    font-size: 0.78rem;
    margin-right: 0.25rem;
}
.pl-payment > i,
.pl-instalment > i {
    color: #15803d;
}
.pl-due > i,
.pl-handover_estimate > i {
    color: #b45309;
}
.pl-future {
    opacity: 0.75;
}
@media (max-width: 640px) {
    .pl-search {
        max-width: none;
        width: 100%;
    }
    .pl-table .pl-date {
        display: none;
    }
}

/* Documents page (documents-page.js) */
.dp-filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.4fr;
    gap: 0.5rem;
}
.dp-table td {
    vertical-align: top;
}
.dp-date,
.dp-size {
    white-space: nowrap;
    color: var(--text-muted, #64748b);
    font-size: 0.82rem;
}
.dp-name {
    word-break: break-word;
    font-weight: 500;
}
.dp-where {
    display: block;
}
.up-doc-name {
    word-break: break-word;
}
@media (max-width: 760px) {
    .dp-filters {
        grid-template-columns: 1fr;
    }
    .dp-size {
        display: none;
    }
}
.dp-src {
    font-size: 0.78rem;
    color: var(--text-secondary, #475569);
    word-break: break-word;
    max-width: 380px;
}

/* unit pop-up hero: gallery + map + brief (unit-hero.js) */
.uh-hero {
    margin-bottom: 1rem;
}
.uh-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 0.9rem;
}
.uh-gallery {
    min-width: 0;
}
.uh-cover {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    background: #0f172a;
    aspect-ratio: 16 / 9;
}
.uh-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.uh-count {
    position: absolute;
    right: 0.6rem;
    bottom: 0.6rem;
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
}
.uh-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.35rem;
    margin-top: 0.4rem;
}
.uh-thumb {
    padding: 0;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    cursor: zoom-in;
    background: var(--bg-card, #fff);
}
.uh-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.uh-thumb.uh-plan img {
    object-fit: contain;
    background: #fff;
}
.uh-more {
    font-weight: 600;
    color: var(--primary-600, #2563eb);
}
.uh-nopic {
    border: 1px dashed var(--border-light, #e2e8f0);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted, #64748b);
}
.uh-side {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-width: 0;
}
.uh-map {
    height: 170px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-light, #e2e8f0);
}
.uh-brief {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-secondary, #334155);
}
.uh-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.7rem;
}
.uh-link {
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--primary-600, #2563eb);
    background: var(--bg-card, #fff);
}
.uh-link:hover {
    background: var(--primary-50, #eff6ff);
}
.uh-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(2, 6, 23, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.uh-lightbox figure {
    margin: 0;
    max-width: 88vw;
    text-align: center;
}
.uh-lightbox img {
    max-width: 88vw;
    max-height: 80vh;
    border-radius: 8px;
    background: #fff;
}
.uh-lightbox figcaption {
    color: #e2e8f0;
    font-size: 0.85rem;
    margin-top: 0.4rem;
}
.uh-lightbox button {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
    border-radius: 999px;
    width: 42px;
    height: 42px;
    cursor: pointer;
}
.uh-lb-x {
    position: absolute;
    top: 1rem;
    right: 1rem;
}
@media (max-width: 760px) {
    .uh-grid {
        grid-template-columns: 1fr;
    }
    .uh-lightbox .uh-lb-prev,
    .uh-lightbox .uh-lb-next {
        position: absolute;
        bottom: 1rem;
    }
    .uh-lb-prev {
        left: 1rem;
    }
    .uh-lb-next {
        right: 1rem;
    }
}
