/* R16 project accounting & cost control – projects-setup.css. Owner: PS – projects, setup & contract (project list & card, WBS editor, BOQ, variations, claims, dashboard). Every class in this file starts with "ps-". */

/* ---------- shared bits */
.ps-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px 16px; text-align: center; color: var(--muted); }
.ps-empty h2 { margin: 0; font-size: 17px; color: var(--text); }
.ps-empty p { margin: 0; max-width: 580px; }
.ps-empty .icon, .ps-empty svg { color: var(--primary); }
.ps-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--blue-bg); color: var(--blue-fg); margin-bottom: 14px; }
.ps-banner.warn { background: var(--amber-bg); color: var(--amber-fg); }
.ps-banner.bad { background: var(--red-bg); color: var(--red-fg); }
.ps-banner > .grow { flex: 1 1 260px; }
.ps-name { display: flex; flex-direction: column; gap: 2px; }
.ps-name .muted { font-size: 12px; }
.ps-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ps-form-note { margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.ps-note { margin: 8px 0 0; }
.ps-section-title { margin: 16px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.ps-dialog-body { max-height: min(70vh, 780px); overflow-y: auto; padding-inline-end: 4px; }
.ps-cur { font-size: 11px; color: var(--muted); margin-inline-start: 4px; font-weight: 500; }
.ps-pad { padding: 12px 16px; }
.ps-calc { display: inline-block; padding: 7px 0; }
.ps-block { display: block; }
.ps-inline { display: inline-flex; align-items: center; gap: 4px; }
.ps-span-2 { grid-column: span 2; }
.ps-desc { white-space: pre-line; margin: 8px 0 0; }
.ps-count { font-size: 11px; padding: 0 6px; border-radius: 999px; background: var(--gray-bg); color: var(--gray-fg); margin-inline-start: 4px; }
.ps-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.ps-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
.ps-col-meter { min-width: 120px; }

/* KPIs that filter a list or open one */
.ps-kpi { text-align: start; cursor: pointer; font: inherit; color: inherit; border: 1px solid var(--border); }
.ps-kpi.on { border-color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.ps-kpi-bad .kpi-value { color: var(--red-fg); }
.ps-kpi-warn .kpi-value { color: var(--amber-fg); }
a.ps-kpi-link { color: inherit; text-decoration: none; }
a.ps-kpi-link:hover .kpi-value, a.ps-kpi-link:focus-visible .kpi-value { color: var(--primary); }

/* tabs of the project card */
.ps-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 14px; border-bottom: 1px solid var(--border); }
.ps-tabs button { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 8px 12px; cursor: pointer;
    border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 4px; }
.ps-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }
.ps-tabs button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* facts (definition lists) */
.ps-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 16px; margin: 0; }
.ps-facts.one { grid-template-columns: 1fr; gap: 8px; }
.ps-facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ps-facts dt { font-size: 12px; color: var(--muted); }
.ps-facts dd { margin: 0; overflow-wrap: anywhere; }
.ps-links { display: flex; flex-direction: column; gap: 6px; }
.ps-links a { display: inline-flex; align-items: center; gap: 6px; }

/* milestone & attention lists */
.ps-ms-list, .ps-attention { list-style: none; margin: 0; padding: 0; }
.ps-ms-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 7px 0; border-bottom: 1px solid var(--row-line); }
.ps-ms-list li:last-child { border-bottom: 0; }
.ps-ms-list .grow { flex: 1 1 160px; min-width: 0; }
.ps-attention { display: flex; flex-direction: column; gap: 6px; }
.ps-attention a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: inherit;
    text-decoration: none; }
.ps-attention a:hover, .ps-attention a:focus-visible { border-color: var(--primary); }
.ps-status-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-status-chips a { text-decoration: none; }

/* timeline */
.ps-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.ps-timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 14px; }
.ps-timeline li::before { content: ""; position: absolute; inset-inline-start: 5px; inset-block: 14px 0; width: 2px; background: var(--row-line); }
.ps-timeline li:last-child::before { display: none; }
.ps-tl-dot { flex: none; width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; background: var(--gray-fg); box-shadow: 0 0 0 3px var(--surface); position: relative; z-index: 1; }
.ps-tl-green .ps-tl-dot { background: var(--green-fg); }
.ps-tl-red .ps-tl-dot { background: var(--red-fg); }
.ps-tl-amber .ps-tl-dot { background: var(--amber-fg); }
.ps-tl-blue .ps-tl-dot { background: var(--blue-fg); }
.ps-tl-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.ps-tl-head { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.ps-note-add { display: flex; gap: 8px; margin-bottom: 14px; }
.ps-note-add input { flex: 1 1 auto; min-width: 0; }

/* ---------- WBS editor */
.ps-wbs-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 10px; }
.ps-wbs-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-width: 0; }
.ps-wbs-sum > :nth-child(2) { width: 140px; }
.ps-wbs-tools { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; }
.ps-wbs-tools .field { margin: 0; }
.ps-drop-top { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.ps-drop-top.on { border-color: var(--primary); color: var(--primary); background: var(--blue-bg); }
table.ps-wbs td { vertical-align: middle; }
.ps-wbs-row[draggable="true"] { cursor: grab; }
.ps-wbs-row.dragging { opacity: .45; }
.ps-wbs-row.drop td { box-shadow: inset 0 -2px 0 var(--primary); }
.ps-wbs-row.parent .ps-wbs-title { font-weight: 600; }
.ps-wbs-name { display: flex; align-items: center; gap: 6px; padding-inline-start: calc(var(--lvl, 0) * 20px); min-width: 220px; }
.ps-wbs-code { font-size: 12px; color: var(--muted); flex: none; }
.ps-wbs-title { min-width: 0; overflow-wrap: anywhere; }
.ps-twisty { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 0; border-radius: 4px; background: transparent;
    color: var(--muted); cursor: pointer; padding: 0; }
.ps-twisty:hover, .ps-twisty:focus-visible { background: var(--gray-bg); color: var(--text); }
.ps-twisty-gap { flex: none; width: 22px; }
.ps-linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--primary); cursor: pointer; text-align: start; }
.ps-linkbtn:hover, .ps-linkbtn:focus-visible { text-decoration: underline; }
.ps-wbs-progress { min-width: 120px; }
.ps-pct-input { width: 80px; }
.ps-ms { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.ps-row-tools { white-space: nowrap; text-align: end; }
.ps-row-tools .icon-btn[disabled] { opacity: .35; }
.ps-rot-up, .ps-rot-down { display: inline-flex; }
.ps-rot-up { transform: rotate(-90deg); }
.ps-rot-down { transform: rotate(90deg); }

/* ---------- contract & BOQ */
.ps-terms { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.ps-terms-head, .ps-boq-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; }
.ps-terms-head h2, .ps-boq-head h2 { margin: 0; font-size: 16px; }
.ps-boq-head .actions { margin: 0; }
.ps-total-bar { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: flex-end; padding: 10px 4px 0; font-size: 14px; }
.ps-paste { width: 100%; font-family: var(--mono); font-size: 12px; }
.ps-preview { max-height: 260px; overflow: auto; }

/* ---------- variation / template lines */
table.ps-lines td { vertical-align: top; }
table.ps-lines input:not([type="checkbox"]), table.ps-lines select { width: 100%; min-width: 90px; }
.ps-small-input { width: 110px !important; min-width: 0 !important; margin-top: 4px; }
.ps-num-input { width: 100px !important; min-width: 0 !important; }

/* ---------- new project: start choices */
.ps-start { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.ps-start-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.ps-start-card:hover, .ps-start-card:focus-visible { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px var(--blue-bg); }
.ps-start-card svg { color: var(--primary); }

/* ---------- templates: list + editor */
.ps-split { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; align-items: start; }
.ps-pick-list { list-style: none; margin: 0; padding: 0; }
.ps-pick-list li { border-bottom: 1px solid var(--row-line); }
.ps-pick-list button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 0; background: transparent;
    color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.ps-pick-list button:hover, .ps-pick-list button:focus-visible { background: var(--gray-bg); outline: none; }
.ps-pick-list li.active button { background: var(--blue-bg); color: var(--blue-fg); }

/* ---------- phone width */
@media (max-width: 760px) {
    .ps-split { grid-template-columns: 1fr; }
    .ps-span-2 { grid-column: auto; }
    .ps-tabs { overflow-x: auto; flex-wrap: nowrap; }
    .ps-tabs button { white-space: nowrap; }
    .ps-wbs-name { min-width: 180px; }
    .ps-total-bar { justify-content: flex-start; }
    .ps-note-add { flex-direction: column; }
}

@media print {
    .ps-tabs, .ps-drop-top, .ps-row-tools, .ps-wbs-tools, .ps-note-add { display: none !important; }
    .ps-terms { border: 0; padding: 0; }
}
