/* RV Cons theme: slate neutrals + blueprint blue accent, on top of Tailwind.
   Meaning colours are kept apart from the brand: green = profit / under budget,
   red = loss / over budget, amber = a value you can edit. */
:root {
    --brand: #1d43c0;
    --brand-hover: #1c389b;
    --brand-ring: rgba(37, 84, 224, .25);
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --muted: #64748b;
    --ink: #0f172a;
}

/* Header navigation */
.nav-link { padding: .4rem .75rem; border-radius: .375rem; font-size: .875rem; font-weight: 500; color: rgba(255,255,255,.72); white-space: nowrap; transition: background .15s, color .15s; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav-link-active { color: #fff; background: rgba(255,255,255,.14); }

/* Page heading */
h1 { letter-spacing: -.015em; }
.page-sub { color: var(--muted); font-size: .875rem; margin-top: .25rem; }
.back-link { display: inline-flex; align-items: center; gap: .25rem; font-size: .8125rem; font-weight: 500; color: var(--muted); }
.back-link:hover { color: var(--brand); }

/* Surfaces */
.card { background: #fff; border: 1px solid var(--border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
a.card { transition: box-shadow .15s, border-color .15s, transform .15s; }
a.card:hover { border-color: var(--border-strong); box-shadow: 0 6px 16px -6px rgba(15,23,42,.15); transform: translateY(-1px); }
.card-title { font-weight: 600; font-size: .9375rem; color: var(--ink); }

/* KPI tiles */
.kpi { background: #fff; border: 1px solid var(--border); border-radius: .75rem; padding: 1rem 1.1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.kpi-label { font-size: .75rem; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 1.25rem; font-weight: 700; margin-top: .15rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }

/* Form controls */
.inp {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: .5rem;
    padding: .45rem .6rem;
    font-size: .875rem;
    background: #fff;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.inp:hover { border-color: #94a3b8; }
.inp:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.inp:disabled { background: #f1f5f9 !important; color: #94a3b8; cursor: not-allowed; }
.inp-sm { padding: .25rem .4rem; font-size: .8125rem; text-align: right; border-radius: .375rem; }
/* Editable numbers keep their amber cue, softened */
.inp.bg-amber-50 { background: #fffbeb; border-color: #fcd9a0; }
.inp.bg-amber-50:focus { border-color: var(--brand); }
.field-label { font-size: .8125rem; font-weight: 500; color: #334155; }
input[type=checkbox] { accent-color: var(--brand); width: 1rem; height: 1rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; border-radius: .5rem; padding: .5rem 1rem; font-size: .875rem; font-weight: 600; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.15); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-light { background: #fff; border: 1px solid var(--border-strong); color: var(--ink); }
.btn-light:hover { background: #f8fafc; }
.link-danger { font-size: .8125rem; font-weight: 500; color: #dc2626; }
.link-danger:hover { text-decoration: underline; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: .6rem 1rem; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: .875rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--ink); border-bottom-color: var(--border-strong); }
.tab-active, .tab-active:hover { color: var(--brand); border-bottom-color: var(--brand); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; border-radius: 9999px; padding: .125rem .6rem; font-size: .75rem; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: .375rem; height: .375rem; border-radius: 9999px; background: currentColor; opacity: .8; }
.badge-planning { background: #f1f5f9; color: #475569; box-shadow: inset 0 0 0 1px #e2e8f0; }
.badge-building { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px #fde68a; }
.badge-completed { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }

/* Alerts */
.alert { display: flex; gap: .6rem; align-items: flex-start; border-radius: .6rem; padding: .7rem 1rem; font-size: .875rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* Tables */
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl { border-collapse: separate; border-spacing: 0; }
.tbl th { font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #f8fafc; padding: .65rem .75rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .55rem .75rem; border-bottom: 1px solid #f1f5f9; font-size: .875rem; vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.row-total td { font-weight: 600; background: #f8fafc; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--border); background: #f8fafc; }

/* Progress */
.progress { height: .375rem; background: #e2e8f0; border-radius: 9999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 9999px; }

/* HTMX saving indicator */
.htmx-request.saving-indicator, .htmx-request .saving-indicator { opacity: 1; }
.saving-indicator { opacity: 0; transition: opacity .2s; }

/* ---------- New project page ---------- */
.btn-lg { padding: .7rem 1.25rem; font-size: .9375rem; border-radius: .6rem; }

/* Hero banner: blueprint grid over a deep blue gradient */
.hero {
    position: relative; overflow: hidden; border-radius: 1rem; padding: 2rem;
    background:
        radial-gradient(1200px 300px at 100% 0%, rgba(59,110,245,.45), transparent 60%),
        linear-gradient(135deg, #111c42 0%, #1b2f6e 55%, #1d43c0 100%);
    box-shadow: 0 20px 40px -24px rgba(17,28,66,.6);
}
.hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(90deg, transparent, #000 45%);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 45%);
}
.hero-step { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem .4rem .4rem; border-radius: 9999px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.65); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); white-space: nowrap; }
.hero-step span { display: grid; place-items: center; width: 1.35rem; height: 1.35rem; border-radius: 9999px; background: rgba(255,255,255,.12); font-size: .7rem; }
.hero-step-active { background: #fff; color: #1b2f6e; }
.hero-step-active span { background: #1d43c0; color: #fff; }
@media (max-width: 640px) { .hero { padding: 1.5rem; } .hero ol { flex-wrap: wrap; } }

/* Section header icon */
.section-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: .65rem; flex-shrink: 0; background: linear-gradient(135deg, #eff4ff, #dbe6fe); color: #1d43c0; box-shadow: inset 0 0 0 1px #bfd3fe; }

/* Inputs with Rs / % / unit adornments */
.adorn { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: .5rem; background: #fff; transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.adorn:hover { border-color: #94a3b8; }
.adorn:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.adorn .inp { border: 0; border-radius: 0; box-shadow: none !important; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; }
.adorn-pre, .adorn-suf { display: flex; align-items: center; padding: 0 .7rem; font-size: .8125rem; color: var(--muted); background: #f8fafc; white-space: nowrap; }
.adorn-pre { border-right: 1px solid var(--border); }
.adorn-suf { border-left: 1px solid var(--border); }

/* Running total under each section */
.calc-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; margin-top: 1.25rem; padding: .65rem .9rem; border-radius: .5rem; background: #f8fafc; border: 1px dashed var(--border-strong); font-size: .8125rem; color: var(--muted); }
.calc-line b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Segmented status picker */
.seg { display: flex; padding: .2rem; gap: .2rem; background: #f1f5f9; border-radius: .55rem; border: 1px solid var(--border); }
.seg label { flex: 1; cursor: pointer; }
.seg span { display: block; text-align: center; padding: .35rem .5rem; border-radius: .4rem; font-size: .8125rem; font-weight: 500; color: var(--muted); transition: all .15s; }
.seg label:hover span { color: var(--ink); }
.seg input:checked + span { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }

/* Live deal preview */
.preview { position: relative; overflow: hidden; border-radius: 1rem; padding: 1.5rem; color: #fff; background: linear-gradient(160deg, #1b2f6e 0%, #111c42 100%); box-shadow: 0 20px 40px -20px rgba(17,28,66,.55); }
.preview::after { content: ""; position: absolute; width: 16rem; height: 16rem; right: -6rem; top: -6rem; border-radius: 9999px; background: radial-gradient(circle, rgba(79,124,247,.35), transparent 70%); pointer-events: none; }
.preview > * { position: relative; z-index: 1; }
.preview-badge { font-size: .7rem; font-weight: 600; padding: .2rem .6rem; border-radius: 9999px; background: rgba(255,255,255,.1); color: #dbe6fe; }
.preview-badge[data-tone=good] { background: rgba(52,211,153,.18); color: #6ee7b7; }
.preview-badge[data-tone=ok]   { background: rgba(96,165,250,.2);  color: #bfdbfe; }
.preview-badge[data-tone=warn] { background: rgba(251,191,36,.18); color: #fcd34d; }
.preview-badge[data-tone=bad]  { background: rgba(248,113,113,.2); color: #fca5a5; }
.stack { display: flex; gap: 2px; height: .65rem; border-radius: 9999px; overflow: hidden; background: rgba(255,255,255,.08); }
.stack > div { height: 100%; transition: width .3s ease; }
.legend { display: flex; align-items: center; gap: .5rem; color: #dbe6fe; }
.legend i { width: .6rem; height: .6rem; border-radius: .15rem; flex-shrink: 0; }
.legend b { margin-left: auto; font-weight: 500; color: #fff; font-variant-numeric: tabular-nums; white-space: pre; }
/* ASP.NET renders an empty <ul> in a valid summary, so hide it explicitly */
.validation-summary-valid { display: none; }
.hero > * { min-width: 0; }

/* ---------- Dashboard ---------- */
/* Glass KPI tiles inside the hero */
.glass { padding: 1rem 1.1rem; border-radius: .8rem; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); backdrop-filter: blur(6px); min-width: 0; }
.glass-label { font-size: .75rem; font-weight: 500; color: #bfd3fe; }
.glass-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; color: #fff; margin-top: .2rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.glass-sub { font-size: .75rem; color: rgba(219,230,254,.75); margin-top: .2rem; }

/* Profit-by-project bars */
.pbar { display: grid; grid-template-columns: minmax(6rem, 10rem) 1fr auto; align-items: center; gap: .9rem; padding: .2rem .35rem; margin: 0 -.35rem; border-radius: .4rem; }
.pbar:hover { background: #f8fafc; }
.pbar-name { font-size: .8125rem; font-weight: 500; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar-track { position: relative; height: 1.1rem; }
.pbar-zero { position: absolute; top: -.2rem; bottom: -.2rem; width: 1px; background: #cbd5e1; }
.pbar-fill { position: absolute; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: #059669; transition: filter .15s; }
.pbar-fill.is-loss { background: #dc2626; border-radius: 4px 0 0 4px; }
.pbar:hover .pbar-fill { filter: brightness(1.1); }
.pbar-val { font-size: .8125rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 6.5rem; }
.pbar-val small { display: block; font-size: .6875rem; font-weight: 500; color: var(--muted); }
@media (max-width: 640px) { .pbar { grid-template-columns: 1fr auto; } .pbar-track { grid-column: 1 / -1; grid-row: 2; } }

/* Status mix */
.seg-bar { display: flex; gap: 2px; height: .65rem; border-radius: 9999px; overflow: hidden; background: #f1f5f9; }
.seg-bar span { height: 100%; }
.st-planning { background: #94a3b8; }
.st-building { background: #f59e0b; }
.st-completed { background: #10b981; }
.stat-chip { display: flex; flex-direction: column; align-items: flex-start; padding: .75rem; border-radius: .6rem; border: 1px solid var(--border); text-align: left; transition: border-color .15s, background .15s; }
.stat-chip:hover { border-color: #bfd3fe; background: #f8fbff; }

/* Search box */
.search { display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; height: 2.4rem; border: 1px solid var(--border-strong); border-radius: .55rem; background: #fff; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.search input { border: 0; outline: 0; font-size: .875rem; width: 12rem; background: transparent; }

/* Project cards */
.pcard { position: relative; display: flex; flex-direction: column; padding: 1.4rem 1.4rem 1.1rem; background: #fff; border: 1px solid var(--border); border-radius: .9rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); overflow: hidden; transition: box-shadow .2s, transform .2s, border-color .2s; }
.pcard::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; }
.st-top-planning::before { background: #94a3b8; }
.st-top-building::before { background: #f59e0b; }
.st-top-completed::before { background: #10b981; }
.pcard:hover { transform: translateY(-3px); border-color: #bfd3fe; box-shadow: 0 18px 36px -18px rgba(27,47,110,.35); }
.pcard-open { margin-top: auto; padding-top: 1rem; font-size: .8125rem; font-weight: 600; color: var(--brand); opacity: .0; transform: translateX(-4px); transition: opacity .2s, transform .2s; }
.pcard:hover .pcard-open, .pcard:focus-visible .pcard-open { opacity: 1; transform: none; }
.pcard-new { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 16rem; padding: 1.5rem; border: 2px dashed var(--border-strong); border-radius: .9rem; color: var(--ink); transition: border-color .2s, background .2s; }
.pcard-new:hover { border-color: var(--brand); background: #f8fbff; }
.rating { display: inline-block; font-size: .6875rem; font-weight: 600; padding: .15rem .55rem; border-radius: 9999px; background: #f1f5f9; color: #475569; }
.rating[data-tone=good] { background: #ecfdf5; color: #047857; }
.rating[data-tone=ok]   { background: #eff4ff; color: #1d43c0; }
.rating[data-tone=warn] { background: #fffbeb; color: #b45309; }
.rating[data-tone=bad]  { background: #fef2f2; color: #b91c1c; }

/* Toggle switch (optional sections such as Financing) */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 2.4rem; height: 1.35rem; border-radius: 9999px; background: #cbd5e1; transition: background .2s; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: .175rem; left: .175rem; width: 1rem; height: 1rem; border-radius: 9999px; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.25); transition: transform .2s; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(1.05rem); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--brand-ring); }
.no-loan { display: flex; align-items: center; gap: .5rem; padding: .65rem .9rem; border-radius: .5rem; background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; font-size: .8125rem; }
.no-loan.hidden { display: none; }

/* Floors editor: one row per storey */
.btn-sm { padding: .35rem .7rem; font-size: .8125rem; }
.floor-row { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) minmax(0, 11rem) 2.25rem; align-items: center; gap: .6rem; }
.floor-num { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: .45rem; background: #eff4ff; color: #1d43c0; font-size: .75rem; font-weight: 700; box-shadow: inset 0 0 0 1px #bfd3fe; }
.floor-del { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .5rem; color: #94a3b8; transition: color .15s, background .15s; }
.floor-del:hover:not(:disabled) { color: #dc2626; background: #fef2f2; }
.floor-del:disabled { opacity: .35; cursor: not-allowed; }
@media (max-width: 480px) { .floor-row { grid-template-columns: 1.75rem minmax(0, 1fr) 2.25rem; } .floor-row .adorn { grid-column: 2 / 3; } }

/* Below-ground floors (counted at half their area) */
.floor-row { grid-template-columns: 1.75rem minmax(0, 1fr) minmax(0, 10rem) auto 2.25rem; }
.below-chip { display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.below-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.below-chip span { display: inline-flex; align-items: center; gap: .3rem; padding: .4rem .65rem; border-radius: .5rem; font-size: .75rem; font-weight: 500; white-space: nowrap; color: var(--muted); border: 1px dashed var(--border-strong); transition: all .15s; }
.below-chip span b { font-weight: 700; }
.below-chip:hover span { color: var(--ink); border-color: #94a3b8; }
.below-chip input:checked + span { color: #92400e; background: #fffbeb; border: 1px solid #fcd34d; }
.below-chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }
.floor-row.is-below .floor-num { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px #fcd34d; }
@media (max-width: 560px) {
    .floor-row { grid-template-columns: 1.75rem minmax(0, 1fr) 2.25rem; }
    .floor-row .adorn, .floor-row .below-chip { grid-column: 2 / 3; }
}

/* ---------- Breadcrumbs: slim bar under the header ---------- */
.crumbbar { background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(15,23,42,.02); }
.crumbs { display: flex; align-items: center; min-height: 2.75rem; gap: .15rem; font-size: .8125rem; overflow: hidden; }
.crumbs > li { display: flex; align-items: center; min-width: 0; flex-shrink: 0; }
.crumbs > li:last-child { flex-shrink: 1; }
.crumb-home a { display: grid; place-items: center; width: 1.85rem; height: 1.85rem; border-radius: .5rem; color: var(--muted); background: #f1f5f9; box-shadow: inset 0 0 0 1px var(--border); transition: color .15s, background .15s, box-shadow .15s; }
.crumb-home a:hover { color: var(--brand); background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; }
/* Chevron separator */
.crumb-sep { width: 1.1rem; height: 1rem; flex-shrink: 0; margin: 0 .1rem; background: #cbd5e1;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7.3 14.7a1 1 0 0 1 0-1.4L10.6 10 7.3 6.7a1 1 0 0 1 1.4-1.4l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4 0Z'/%3E%3C/svg%3E") center / 1rem no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M7.3 14.7a1 1 0 0 1 0-1.4L10.6 10 7.3 6.7a1 1 0 0 1 1.4-1.4l4 4a1 1 0 0 1 0 1.4l-4 4a1 1 0 0 1-1.4 0Z'/%3E%3C/svg%3E") center / 1rem no-repeat; }
.crumb-link, .crumb-current { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .55rem; border-radius: .45rem; min-width: 0; max-width: 18rem; }
.crumb-link { color: var(--muted); font-weight: 500; transition: color .15s, background .15s; }
.crumb-link:hover { color: var(--brand); background: #eff4ff; }
.crumb-current { color: var(--ink); font-weight: 600; background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); }
.crumb-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-icon { width: 1rem; height: 1rem; flex-shrink: 0; opacity: .85; }
.crumb-current .crumb-icon { color: var(--brand); opacity: 1; }
.crumb-dot { width: .45rem; height: .45rem; border-radius: 9999px; flex-shrink: 0; box-shadow: 0 0 0 2px #fff; }
.crumb-more { display: none; }
.crumb-ellipsis { padding: .2rem .4rem; color: var(--muted); letter-spacing: .1em; }
@media (max-width: 640px) {
    .crumb-mid { display: none; }
    .crumb-more { display: flex; }
    .crumb-link, .crumb-current { max-width: 11rem; }
}
/* Breadcrumb fixes: beat `.crumbs > li { display:flex }`, and truncate the middle steps before the current page */
.crumbs > li { flex-shrink: 1; }
.crumbs > li.crumb-home, .crumbs > li:last-child { flex-shrink: 0; max-width: 60%; }
.crumbs > li.crumb-more { display: none; }
@media (max-width: 640px) {
    .crumbs > li.crumb-mid { display: none; }
    .crumbs > li.crumb-more { display: flex; flex-shrink: 0; }
}

/* ---------- Contract cards (Cost tracker) ---------- */
.ccard { display: flex; flex-direction: column; padding: 1.1rem 1.2rem 1rem; background: #fff; border: 1px solid var(--border); border-radius: .9rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: border-color .2s, box-shadow .2s; }
.ccard:hover, .ccard:focus-within { border-color: #bfd3fe; box-shadow: 0 12px 28px -18px rgba(27,47,110,.35); }
.ccard-name { flex: 1; min-width: 0; font-weight: 600; font-size: .975rem; color: var(--ink); border: 1px solid transparent; border-radius: .4rem; padding: .3rem .4rem; margin: -.1rem 0 0 -.4rem; background: transparent; }
.ccard-name:hover { border-color: var(--border); }
.ccard-name:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: #fff; }
.ccard-field { display: flex; align-items: center; gap: .4rem; min-width: 0; padding: 0 .55rem; height: 2.2rem; border: 1px solid var(--border-strong); border-radius: .5rem; transition: border-color .15s, box-shadow .15s; }
.ccard-field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.ccard-field input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: .8125rem; background: transparent; }
.ccard-money { margin-top: 1rem; padding: .85rem .9rem; border-radius: .65rem; background: linear-gradient(135deg, #f8fafc, #eff4ff); box-shadow: inset 0 0 0 1px #e2e8f0; }
.ccard-notes { margin-top: .75rem; width: 100%; font-size: .75rem; color: var(--muted); border: 0; border-top: 1px dashed var(--border); padding: .6rem 0 0; background: transparent; outline: 0; }
.ccard-notes:focus { color: var(--ink); }
.ccard .inp { padding-top: .4rem; padding-bottom: .4rem; }
/* Material supplied by a contract */
.tbl tr.row-muted td { background: #fafafa; color: #94a3b8; }
.tbl tr.row-muted td .font-medium { color: #64748b; }

/* Library estimate on the New project page */
.lib-est { display: flex; align-items: center; gap: .75rem; margin-top: 1.25rem; padding: .75rem .9rem; border-radius: .6rem; background: linear-gradient(135deg, #f8fbff, #eff4ff); box-shadow: inset 0 0 0 1px #dbe6fe; }
.lib-est .btn:disabled { opacity: .7; cursor: default; color: #047857; border-color: #a7f3d0; background: #ecfdf5; }

/* Quick add from library + partial-area pill */
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.chip { display: inline-flex; align-items: center; padding: .3rem .7rem; border-radius: 9999px; font-size: .75rem; font-weight: 500; color: var(--brand); background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; transition: background .15s, color .15s; }
.chip:hover { background: var(--brand); color: #fff; }
.area-pill { display: inline-block; padding: 0 .4rem; margin-right: .2rem; border-radius: 9999px; background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px #fde68a; font-weight: 600; }

/* Contractor contact cards */
.avatar { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex-shrink: 0; border-radius: 9999px; font-size: .8rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, #3b6ef5, #1b2f6e); box-shadow: 0 0 0 3px #eff4ff; }
.linked-contact { display: inline-flex; align-items: center; gap: .25rem; font-size: .6875rem; font-weight: 500; color: #047857; }
.linked-contact:hover { text-decoration: underline; }

/* ---------- Picker dropdown (contractors, trades) ---------- */
input[data-picker] { cursor: pointer; padding-right: 1.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.2 7.2a.75.75 0 0 1 1.06.04L10 11.2l3.74-3.96a.75.75 0 1 1 1.1 1.02l-4.3 4.5a.75.75 0 0 1-1.1 0l-4.3-4.5a.75.75 0 0 1 .06-1.06Z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .1rem center; background-size: 1.05rem; }
input.inp[data-picker] { padding-right: 2rem; background-position: right .55rem center; }
input[data-picker]:focus { cursor: text; }
input[data-picker][aria-expanded="true"] { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231d43c0'%3E%3Cpath fill-rule='evenodd' d='M14.8 12.8a.75.75 0 0 1-1.06-.04L10 8.8l-3.74 3.96a.75.75 0 1 1-1.1-1.02l4.3-4.5a.75.75 0 0 1 1.1 0l4.3 4.5a.75.75 0 0 1-.06 1.06Z' clip-rule='evenodd'/%3E%3C/svg%3E"); }

.picker { position: fixed; z-index: 60; overflow-y: auto; padding: .35rem; background: rgba(255,255,255,.98); backdrop-filter: blur(10px);
    border: 1px solid var(--border); border-radius: .8rem;
    box-shadow: 0 18px 40px -12px rgba(15,23,42,.28), 0 4px 10px -4px rgba(15,23,42,.08);
    animation: picker-in .14s ease-out; }
.picker[data-up="1"] { animation-name: picker-up; }
@keyframes picker-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes picker-up { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.picker-group { padding: .5rem .6rem .25rem; font-size: .625rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #94a3b8; }
.picker-opt { display: flex; align-items: center; gap: .65rem; padding: .45rem .55rem; border-radius: .55rem; cursor: pointer; transition: background .1s; }
.picker-opt.is-active { background: #eff4ff; }
.picker-opt.is-active .picker-name { color: var(--brand); }
.picker-av { display: grid; place-items: center; width: 2rem; height: 2rem; flex-shrink: 0; border-radius: 9999px; font-size: .6875rem; font-weight: 700; color: #fff; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--border); }
.av-0 { background: linear-gradient(135deg, #3b6ef5, #1b2f6e); }
.av-1 { background: linear-gradient(135deg, #10b981, #065f46); }
.av-2 { background: linear-gradient(135deg, #f59e0b, #b45309); }
.av-3 { background: linear-gradient(135deg, #ec4899, #9d174d); }
.av-4 { background: linear-gradient(135deg, #8b5cf6, #4c1d95); }
.av-5 { background: linear-gradient(135deg, #06b6d4, #155e75); }
.picker-plus { background: #fff; color: var(--brand); font-size: 1rem; box-shadow: inset 0 0 0 1.5px var(--brand); border: 0; }
.picker-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.picker-name { font-size: .8125rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-sub { font-size: .6875rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-phone { flex-shrink: 0; font-size: .6875rem; font-variant-numeric: tabular-nums; color: var(--muted); padding: .15rem .45rem; border-radius: 9999px; background: #f1f5f9; }
.picker-opt.is-active .picker-phone { background: #dbe6fe; color: var(--brand); }
.picker-ico { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: .4rem; background: #f1f5f9; color: #94a3b8; font-size: .75rem; font-weight: 700; }
.picker mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }
.picker-new { border-top: 1px dashed var(--border); border-radius: 0 0 .55rem .55rem; margin-top: .2rem; }
.picker-empty { padding: 1rem .75rem; text-align: center; font-size: .75rem; color: var(--muted); }
.picker-foot { display: block; margin: .3rem -.35rem -.35rem; padding: .55rem .9rem; font-size: .75rem; font-weight: 600; color: var(--brand); background: #f8fafc; border-top: 1px solid var(--border); position: sticky; bottom: -.35rem; }
.picker-foot:hover { background: #eff4ff; }
.picker-opt.is-selected::after { content: ""; width: 1rem; height: 1rem; flex-shrink: 0; background: var(--brand);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4L8 12.6l7.3-7.3a1 1 0 0 1 1.4 0Z'/%3E%3C/svg%3E") center/contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4L8 12.6l7.3-7.3a1 1 0 0 1 1.4 0Z'/%3E%3C/svg%3E") center/contain no-repeat; }

/* ---------- Contracts: Cards / Rows view ---------- */
.view-toggle { display: inline-flex; padding: .2rem; gap: .2rem; background: #f1f5f9; border: 1px solid var(--border); border-radius: .55rem; }
.view-toggle button { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: .4rem; font-size: .75rem; font-weight: 600; color: var(--muted); transition: all .15s; }
.view-toggle button:hover { color: var(--ink); }
.view-toggle button[aria-pressed="true"] { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.view-toggle button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.ct-wrap { overflow-x: auto; margin: -.5rem; padding: .5rem; }

/* Small cards: denser grid, extras hidden (notes, hints) */
.ct-list.ct-small { grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: .75rem; }
.ct-small .ccard { padding: .7rem .75rem .65rem; border-radius: .75rem; }
.ct-small .cc-head { align-items: center; gap: .4rem; }
.ct-small .cc-head .section-icon { display: none; }
.ct-small .ccard-name { font-size: .875rem; padding: .2rem .35rem; margin-left: -.35rem; }
.ct-small .floor-del { width: 1.6rem; height: 1.6rem; }
.ct-small .cc-who { grid-template-columns: 1.35fr 1fr; gap: .35rem; margin-top: .5rem !important; }
.ct-small .ccard-field { height: 1.95rem; padding: 0 .4rem; gap: .3rem; }
.ct-small .ccard-field > svg { display: none; }
.ct-small .ccard-field input { font-size: .75rem; }
.ct-small .cc-link, .ct-small .cc-note, .ct-small .cc-notes, .ct-small .cc-sup { display: none; }
.ct-small .cc-price { gap: .35rem; margin-top: .35rem !important; }
.ct-small .cc-rate { margin-top: .35rem !important; }
.ct-small .inp { font-size: .75rem; padding: .3rem .45rem; }
.ct-small .adorn-pre, .ct-small .adorn-suf { padding: 0 .4rem; font-size: .6875rem; }
.ct-small .cc-mat { margin-top: .45rem !important; }
.ct-small .cc-mat .text-xs { font-size: .6875rem; }
.ct-small .cc-money { margin-top: .55rem; padding: .5rem .6rem; }
.ct-small .cc-money .kpi-label { font-size: .625rem; }
.ct-small .cc-money .text-xl { font-size: 1rem; }
.ct-small .cc-money .text-xs { font-size: .6875rem; }
.ct-small .cc-money .progress { margin-top: .4rem; height: .3rem; }
.ct-small .cc-money .text-\[11px\] { display: none; }

/* ---------- Contracts: Rows view (a clean, editable table) ---------- */
.ct-head { display: none; }
.ct-list.ct-rows {
    --ct-cols: minmax(210px, 1.35fr) minmax(240px, 1.25fr) minmax(255px, 1.4fr) minmax(120px, .7fr) 76px 205px;
    display: block; min-width: 1180px; background: #fff; border: 1px solid var(--border); border-radius: .9rem;
    box-shadow: 0 1px 2px rgba(15,23,42,.04); overflow: hidden;
}
.ct-rows .ct-head {
    display: grid; grid-template-columns: var(--ct-cols); column-gap: 1rem; align-items: center;
    padding: .6rem 1.1rem .6rem 1.35rem; background: #f8fafc; border-bottom: 1px solid var(--border);
    font-size: .6875rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.ct-rows .ccard {
    position: relative; display: grid; grid-template-columns: var(--ct-cols); column-gap: 1rem; row-gap: .15rem; align-items: center;
    grid-template-areas: "head who price rate mat money" "notes link note sup sup money";
    padding: .6rem 1.1rem .55rem 1.35rem; border: 0; border-radius: 0; box-shadow: none;
    border-bottom: 1px solid #eef2f7; transition: background .15s;
}
.ct-rows .ccard:last-child { border-bottom: 0; }
.ct-rows .ccard:hover { background: #fafcff; box-shadow: none; }
.ct-rows .ccard:focus-within { background: #f5f8ff; box-shadow: none; }
/* status bar on the left: not started / part paid / fully paid / over budget */
.ct-rows .ccard::before { content: ""; position: absolute; left: 0; top: .55rem; bottom: .55rem; width: 3px; border-radius: 0 3px 3px 0; background: #cbd5e1; }
.ct-rows .ccard[data-state="part"]::before { background: var(--brand); }
.ct-rows .ccard[data-state="paid"]::before { background: #10b981; }
.ct-rows .ccard[data-state="over"]::before { background: #ef4444; }
.ct-rows .ccard > * { margin-top: 0 !important; }

.ct-rows .cc-head  { grid-area: head; gap: .25rem; align-items: center; }
.ct-rows .cc-head .section-icon { display: none; }
.ct-rows .ccard-name { font-size: .875rem; font-weight: 600; margin-left: -.4rem; padding: .25rem .4rem; }
.ct-rows .cc-head .floor-del { width: 1.75rem; height: 1.75rem; opacity: 0; }
.ct-rows .ccard:hover .floor-del, .ct-rows .ccard:focus-within .floor-del { opacity: 1; }
.ct-rows .cc-who   { grid-area: who; gap: .35rem; grid-template-columns: 1.25fr 1fr; }
.ct-rows .cc-link  { grid-area: link; justify-self: start; font-size: .65rem; }
.ct-rows .cc-price { grid-area: price; gap: .35rem; }
.ct-rows .cc-note  { display: none; }
.ct-rows .cc-rate  { grid-area: rate; }
.ct-rows .cc-mat   { grid-area: mat; justify-self: center; }
.ct-rows .cc-mat-text { display: none; }
.ct-rows .cc-sup   { grid-area: sup; font-size: .65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-rows .cc-notes { grid-area: notes; border: 0; padding: 0; font-size: .7rem; color: #94a3b8; }
.ct-rows .cc-notes:focus, .ct-rows .cc-notes:not(:placeholder-shown) { color: var(--muted); }

/* spreadsheet-style fields: quiet until you point at the row */
.ct-rows .ccard-field, .ct-rows .inp, .ct-rows .adorn { border-color: transparent; background-color: transparent; box-shadow: none; height: 2rem; }
.ct-rows .ccard-field { padding: 0 .45rem; }
.ct-rows .ccard-field > svg { color: #cbd5e1; }
.ct-rows .inp { font-size: .8125rem; padding: .3rem .5rem; }
.ct-rows .inp.bg-amber-50, .ct-rows .adorn .inp { background-color: transparent; }
.ct-rows .adorn-pre, .ct-rows .adorn-suf { background: transparent; border: 0; padding: 0 .4rem; font-size: .7rem; color: #94a3b8; }
.ct-rows .adorn .inp { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ct-rows .ccard:hover :is(.ccard-field, .inp, .adorn) { border-color: var(--border); background-color: #fff; }
.ct-rows .ccard:hover .adorn .inp { border-color: transparent; }
.ct-rows :is(.ccard-field, .adorn):focus-within, .ct-rows .inp:focus { border-color: var(--brand) !important; background-color: #fff; box-shadow: 0 0 0 3px var(--brand-ring); }
.ct-rows .adorn .inp:focus { box-shadow: none; }
.ct-rows select.inp { padding-right: 1.6rem; }

/* amount column: number on top, thin paid bar, paid / balance below */
.ct-rows .cc-money { grid-area: money; align-self: center; background: none; box-shadow: none; padding: 0; border-left: 1px solid #eef2f7; padding-left: 1rem; }
.ct-rows .cc-money > .flex { align-items: baseline; }
.ct-rows .cc-money .kpi-label { display: none; }
.ct-rows .cc-money .text-xl { font-size: .975rem; }
.ct-rows .cc-money .text-right { display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; font-size: .6875rem; line-height: 1.3; }
.ct-rows .cc-money .progress { margin-top: .35rem; height: .25rem; }
.ct-rows .cc-pct { display: none; }
.ct-rows .cc-price { grid-template-columns: 122px minmax(0, 1fr) minmax(0, 1fr); }
.ct-rows .cc-price > * { grid-column: auto; }
.ct-rows .cc-price > .adorn, .ct-rows .cc-price > span { grid-column: span 2; }
.ct-rows .cc-rate .adorn-suf { display: none; }

/* ---------- Contractor + call, one field ---------- */
.who-field { padding-right: .25rem; }
.who-field input[data-picker] { min-width: 0; }
.call-btn { display: inline-flex; align-items: center; gap: .3rem; flex-shrink: 0; height: 1.65rem; padding: 0 .55rem 0 .45rem; border-radius: 9999px;
    background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; font-size: .6875rem; font-weight: 600; font-variant-numeric: tabular-nums;
    transition: background .15s, color .15s, box-shadow .15s; }
.call-btn:hover { background: #10b981; color: #fff; box-shadow: 0 4px 10px -4px rgba(16,185,129,.6); }
.call-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(16,185,129,.35); }
.call-add { flex-shrink: 0; font-size: .6875rem; font-weight: 600; color: #94a3b8; padding: 0 .4rem; }
.call-add:hover { color: var(--brand); }
/* compact layouts: just the round call button (number on hover) */
:is(.ct-rows, .ct-small) .call-btn { width: 1.65rem; padding: 0; justify-content: center; }
:is(.ct-rows, .ct-small) .call-num { display: none; }
.ct-rows .cc-who { display: block; }

/* ---------- Modal dialog (Add a line) ---------- */
dialog.modal { width: min(36rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 1rem; background: #fff; color: var(--ink);
    box-shadow: 0 30px 60px -20px rgba(15,23,42,.45), 0 0 0 1px rgba(15,23,42,.06); overflow: visible; }
dialog.modal[open] { animation: modal-in .18s ease-out; }
dialog.modal::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(3px); animation: fade-in .18s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; gap: .85rem; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #f8fbff, #fff); border-radius: 1rem 1rem 0 0; }
.modal-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.modal-sub { font-size: .8125rem; color: var(--muted); margin-top: .1rem; }
.modal-x { display: grid; place-items: center; width: 2rem; height: 2rem; margin: -.25rem -.25rem 0 0; border-radius: .5rem; color: #94a3b8; transition: all .15s; }
.modal-x:hover { color: var(--ink); background: #f1f5f9; }
.modal-body { padding: 1.1rem 1.25rem 1.25rem; max-height: calc(100vh - 12rem); overflow-y: auto; }
.modal-est { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.1rem; padding: .8rem 1rem; border-radius: .7rem;
    background: linear-gradient(135deg, #eff4ff, #f8fafc); box-shadow: inset 0 0 0 1px #dbe6fe; }
.modal-est b { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.modal-est-how { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.modal-foot { display: flex; align-items: center; gap: .6rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: #f8fafc; border-radius: 0 0 1rem 1rem; }

/* ---------- Toast notifications ---------- */
.toasts { position: fixed; z-index: 80; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; pointer-events: none; width: min(24rem, calc(100vw - 2rem)); }
.toast { position: relative; pointer-events: auto; display: flex; align-items: flex-start; gap: .75rem; width: 100%; padding: .85rem .9rem .9rem; overflow: hidden;
    background: rgba(255,255,255,.97); backdrop-filter: blur(10px); border-radius: .85rem;
    box-shadow: 0 20px 40px -16px rgba(15,23,42,.35), 0 0 0 1px rgba(15,23,42,.07); animation: toast-in .32s cubic-bezier(.21,1.02,.73,1); }
.toast-out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.96); } }
.toast-ico { display: grid; place-items: center; flex-shrink: 0; width: 2rem; height: 2rem; border-radius: 9999px; }
.toast-ico svg { width: 1.1rem; height: 1.1rem; }
.toast-body { flex: 1; min-width: 0; padding-top: .05rem; }
.toast-title { font-size: .8125rem; font-weight: 700; color: var(--ink); }
.toast-msg { font-size: .8125rem; color: #475569; line-height: 1.4; margin-top: .05rem; overflow-wrap: anywhere; }
.toast-x { display: grid; place-items: center; flex-shrink: 0; width: 1.6rem; height: 1.6rem; margin: -.2rem -.3rem 0 0; border-radius: .4rem; color: #94a3b8; }
.toast-x svg { width: 1rem; height: 1rem; }
.toast-x:hover { color: var(--ink); background: #f1f5f9; }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: toast-life linear forwards; animation-play-state: paused; opacity: .85; }
@keyframes toast-life { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.toast-success .toast-ico { background: #d1fae5; color: #047857; } .toast-success .toast-bar { background: #10b981; }
.toast-info    .toast-ico { background: #dbe6fe; color: var(--brand); } .toast-info .toast-bar { background: var(--brand); }
.toast-warning .toast-ico { background: #fef3c7; color: #b45309; } .toast-warning .toast-bar { background: #f59e0b; }
.toast-error   .toast-ico { background: #fee2e2; color: #dc2626; } .toast-error .toast-bar { background: #ef4444; }
.toast-error { box-shadow: 0 20px 40px -16px rgba(220,38,38,.35), 0 0 0 1px #fecaca; }

/* quiet auto-save: a slim dark pill */
.toast-saved { width: auto; max-width: 100%; align-items: center; gap: .5rem; padding: .5rem .9rem .5rem .55rem; border-radius: 9999px;
    background: rgba(17,28,66,.94); box-shadow: 0 12px 28px -12px rgba(15,23,42,.55); }
.toast-saved .toast-ico { width: 1.35rem; height: 1.35rem; background: #10b981; color: #fff; }
.toast-saved .toast-ico svg { width: .85rem; height: .85rem; }
.toast-saved .toast-msg { color: #e2e8f0; font-size: .78rem; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .toasts { right: 1rem; left: 1rem; bottom: 1rem; width: auto; align-items: stretch; } .toast-saved { align-self: center; } }

/* ---------- Material categories ---------- */
:root {
    /* one clearly different colour per category (text labels always go with them) */
    --cat-c0: #c2410c;  /* Construction: brick */
    --cat-c1: #eab308;  /* Electrical & appliances: yellow */
    --cat-c2: #0891b2;  /* Plumbing & sanitary: water blue */
    --cat-c3: #4f46e5;  /* Tiles & granite: indigo */
    --cat-c4: #db2777;  /* Colour & paint: pink */
    --cat-c5: #0d9488;  /* Doors & windows: teal */
    --cat-c6: #f97316;  /* Kitchen: orange */
    --cat-c7: #9333ea;  /* Furniture: purple */
    --cat-c8: #16a34a;  /* Fees & connections: green */
    --cat-c9: #854d0e;  /* Other: brown */
    /* your own categories: picked from the name */
    --cat-c10: #2563eb; --cat-c11: #c026d3; --cat-c12: #65a30d; --cat-c13: #e11d48; --cat-c14: #0284c7; --cat-c15: #64748b;
    --cat-c98: #3b6ef5; /* contracts */
    --cat-c99: #cbd5e1; /* uncategorised */
}
.cat-c0 { background: var(--cat-c0); } .cat-c1 { background: var(--cat-c1); } .cat-c2 { background: var(--cat-c2); }
.cat-c3 { background: var(--cat-c3); } .cat-c4 { background: var(--cat-c4); } .cat-c5 { background: var(--cat-c5); }
.cat-c6 { background: var(--cat-c6); } .cat-c7 { background: var(--cat-c7); } .cat-c8 { background: var(--cat-c8); }
.cat-c9 { background: var(--cat-c9); } .cat-c10 { background: var(--cat-c10); } .cat-c99 { background: var(--cat-c99); }
.cat-c11 { background: var(--cat-c11); } .cat-c12 { background: var(--cat-c12); } .cat-c13 { background: var(--cat-c13); }
.cat-c14 { background: var(--cat-c14); } .cat-c15 { background: var(--cat-c15); } .cat-c98 { background: var(--cat-c98); }
.cat-dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 9999px; flex-shrink: 0; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(15,23,42,.08); }

.cat-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .85rem; }
.cat-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .7rem; border-radius: 9999px; font-size: .78rem; font-weight: 600; color: #475569;
    background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: all .15s; }
.cat-chip:hover { border-color: var(--border-strong); color: var(--ink); }
.cat-chip.is-on { background: var(--brand-950, #111c42); border-color: transparent; color: #fff; box-shadow: 0 6px 14px -8px rgba(17,28,66,.7); }
.cat-chip.is-on .cat-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.cat-n { font-size: .6875rem; font-weight: 700; padding: 0 .4rem; border-radius: 9999px; background: #f1f5f9; color: var(--muted); }
.cat-chip.is-on .cat-n { background: rgba(255,255,255,.15); color: #fff; }
.cat-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.tbl tr.cat-row td { background: linear-gradient(90deg, #f8fafc, #fff); border-top: 1px solid var(--border); padding-top: .55rem; padding-bottom: .55rem;
    font-weight: 600; color: var(--ink); }
.tbl tr.cat-row td.num { font-size: .8125rem; }
.cat-head { display: inline-flex; align-items: center; gap: .55rem; font-size: .8125rem; letter-spacing: .01em; }
.cat-count { font-size: .6875rem; font-weight: 500; color: var(--muted); margin-left: .15rem; }
.tbl tr.cat-item td:first-child { box-shadow: inset 3px 0 0 var(--cat, transparent); padding-left: 1rem; }

/* ---------- Order sizes (loads) ---------- */
.load-edit { display: inline-flex; align-items: center; gap: .3rem; margin-top: .3rem; padding: .1rem .2rem .1rem .45rem; border-radius: 9999px;
    background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); font-size: .6875rem; color: var(--muted); }
.load-edit:focus-within { box-shadow: inset 0 0 0 1px var(--brand), 0 0 0 3px var(--brand-ring); background: #fff; }
.load-edit span { white-space: nowrap; }
.load-edit input { width: 4.75rem; border: 0; outline: 0; background: transparent; font-size: .6875rem; font-weight: 600; color: var(--ink); }
.load-edit input::placeholder { font-weight: 400; color: #94a3b8; }
.load-hint { margin-top: .15rem; font-size: .6875rem; font-weight: 600; color: #b45309; white-space: nowrap; }
.load-hint.load-more { color: var(--brand); }
.load-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.load-chip { padding: .15rem .55rem; border-radius: 9999px; font-size: .6875rem; font-weight: 700; color: #b45309; background: #fffbeb;
    box-shadow: inset 0 0 0 1px #fde68a; transition: all .15s; }
.load-chip:hover { background: #f59e0b; color: #fff; box-shadow: none; }
.load-chip.load-clear { color: #94a3b8; background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); }
.load-chip.load-clear:hover { color: #dc2626; background: #fef2f2; }
.tbl td input[name="category"] { min-width: 10.5rem; }

/* ---------- Material library ---------- */
.lib-hero .glass-value { font-size: 1.5rem; }
.lib-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.lib-tabs { display: inline-flex; padding: .25rem; gap: .25rem; background: #fff; border: 1px solid var(--border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.lib-tabs button { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-radius: .55rem; font-size: .875rem; font-weight: 600; color: var(--muted); transition: all .15s; }
.lib-tabs button:hover { color: var(--ink); background: #f8fafc; }
.lib-tabs button[aria-selected="true"] { background: var(--brand); color: #fff; box-shadow: 0 6px 14px -8px rgba(29,67,192,.8); }
.lib-tabs button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.lib-tab-n { font-size: .6875rem; font-weight: 700; padding: .05rem .45rem; border-radius: 9999px; background: #f1f5f9; color: var(--muted); }
.lib-tabs button[aria-selected="true"] .lib-tab-n { background: rgba(255,255,255,.2); color: #fff; }
.lib-search input { width: 16rem; }
.lib-pane-sub { font-size: .8125rem; color: var(--muted); margin: 0 0 .75rem; }
.lib-empty { padding: 2.5rem 1rem; text-align: center; font-size: .875rem; color: var(--muted); }

/* the table: quiet fields that show their borders when you point at the row */
.lib-table td { padding-top: .45rem; padding-bottom: .45rem; vertical-align: middle; }
.lib-table tr.lib-row td:first-child { box-shadow: inset 3px 0 0 var(--cat, transparent); }
.lib-table tr.lib-row:hover td { background: #fafcff; }
.lib-table tr.lib-row:focus-within td { background: #f5f8ff; }
.lib-table .inp { height: 2.1rem; padding: .3rem .5rem; font-size: .8125rem; border-color: transparent; background-color: transparent; box-shadow: none; }
.lib-table select.inp { padding-right: 1.6rem; }
.lib-table tr.lib-row:hover .inp, .lib-table tr.lib-row:hover .adorn { border-color: var(--border); background-color: #fff; }
.lib-table .adorn { border-color: transparent; background: transparent; box-shadow: none; height: 2.1rem; }
.lib-table .adorn .inp { border: 0 !important; height: 100%; }
.lib-table .adorn-pre { background: transparent; border: 0; padding: 0 .1rem 0 .5rem; font-size: .7rem; color: #94a3b8; }
.lib-table .inp:focus, .lib-table .adorn:focus-within { border-color: var(--brand) !important; background-color: #fff !important; box-shadow: 0 0 0 3px var(--brand-ring); }
.lib-table .adorn .inp:focus { box-shadow: none; }
.lib-table .lib-edit { font-weight: 600; font-variant-numeric: tabular-nums; color: #92400e; }
.lib-table .lib-rate .inp { text-align: right; }
.lib-order .inp { width: 3.2rem; text-align: center; color: #94a3b8; font-size: .75rem; }
.lib-name { min-width: 15rem; }
.lib-name-inp { font-weight: 600 !important; color: var(--ink); width: 100%; }
.lib-note { display: block; width: 100%; margin-top: .05rem; padding: .1rem .5rem; border: 0; outline: 0; background: transparent; font-size: .7rem; color: #94a3b8; }
.lib-note:focus, .lib-note:not(:placeholder-shown) { color: var(--muted); }
.lib-note:focus { color: var(--ink); }
.lib-dash { display: block; text-align: right; padding-right: .5rem; color: #cbd5e1; }
.lib-amount { font-weight: 700; color: var(--ink); white-space: nowrap; }
.lib-kind { width: auto !important; color: var(--muted); font-size: .75rem !important; }
.lib-badge { display: inline-flex; align-items: center; gap: .25rem; margin-left: .25rem; padding: .1rem .5rem; border-radius: 9999px; font-size: .65rem; font-weight: 600; white-space: nowrap; max-width: 11rem; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.lib-badge-learned { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px #a7f3d0; }
.lib-table tfoot td { font-size: .8125rem; }
.lib-sub { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.lib-sub .lib-badge { margin-left: .5rem; flex-shrink: 0; }
.lib-sub .lib-note { flex: 1; min-width: 0; }
.lib-table select[name="basis"] { min-width: 7.6rem; }
.lib-table input[name="area"], .lib-table input[name="qty"] { min-width: 5.5rem; }
.lib-table .lib-rate { max-width: 9.5rem; margin-left: auto; }
.lib-table .lib-order { width: 3.5rem; }
.lib-table select.lib-kind { min-width: 6.5rem; }
.lib-table input[name="unit"] { min-width: 5rem; }
.lib-table .lib-rate { min-width: 8.5rem; max-width: 10rem; }
.lib-table .lib-rate .inp { min-width: 5.5rem; }
/* compact columns so the library fits without a sideways scroll */
.lib-table th, .lib-table td { padding-left: .45rem; padding-right: .45rem; }
.lib-table th:first-child, .lib-table td:first-child { padding-left: .8rem; }
.lib-table th { font-size: .65rem; }
.lib-table .lib-order, .lib-table th:first-child { width: 3rem; }
.lib-order .inp { width: 2.6rem; padding-left: .2rem; padding-right: .2rem; }
.lib-name { min-width: 13rem; }
.lib-table input[name="category"] { min-width: 9rem; }
.lib-table select[name="basis"] { min-width: 7.2rem; }
.lib-table input[name="area"], .lib-table input[name="qty"] { min-width: 4.5rem; width: 5rem; }
.lib-table input[name="unit"] { min-width: 4.25rem; width: 5rem; }
.lib-table input[name="loadSizes"] { width: 5.5rem; }
.lib-table .lib-rate { min-width: 7.5rem; max-width: 8.5rem; }
.lib-table .lib-rate .inp { min-width: 4.75rem; }
.lib-table select.lib-kind { min-width: 5.75rem; padding-right: 1.4rem; }

/* ---------- Picker: item mode (Spending log) ---------- */
.picker-item-ico { display: grid; place-items: center; flex-shrink: 0; width: 2rem; height: 2rem; border-radius: .55rem;
    color: var(--c, #64748b); background: color-mix(in srgb, var(--c, #64748b) 12%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #64748b) 25%, white); }
.picker-item-ico svg { width: 1rem; height: 1rem; }

/* ---------- Spending log ---------- */
.sp-kpi { position: relative; padding-right: 3.5rem; }
.sp-kpi-ico { position: absolute; top: 1rem; right: 1rem; display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .65rem; }
.sp-kpi-ico svg { width: 1.15rem; height: 1.15rem; }

.sp-form { overflow: visible; }
.sp-form-head { display: flex; align-items: center; gap: .85rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #f8fbff, #fff); border-radius: .75rem .75rem 0 0; }
.sp-form-body { padding: 1.1rem 1.25rem 1.25rem; }
.sp-item { padding-right: 2rem; font-weight: 600; }
.sp-amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.sp-comments { resize: vertical; min-height: 2.6rem; line-height: 1.4; }
.sp-rate-hint { min-height: 1rem; margin-top: .3rem; font-size: .6875rem; font-weight: 600; color: var(--muted); }
.sp-rate-hint.is-under { color: #047857; }
.sp-rate-hint.is-over { color: #b45309; }
.sp-item-info { display: flex; align-items: center; gap: .5rem; padding: .55rem .8rem; border-radius: .6rem; font-size: .78rem; color: #92400e;
    background: #fffbeb; box-shadow: inset 0 0 0 1px #fde68a; }
.sp-item-info.is-contract { color: #1c389b; background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; }
.sp-item-info::before { content: "i"; display: grid; place-items: center; flex-shrink: 0; width: 1.1rem; height: 1.1rem; border-radius: 9999px;
    font-size: .65rem; font-weight: 700; font-style: italic; color: #fff; background: currentColor; }
.sp-item-info.hidden { display: none; }

.sp-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.sp-log { overflow: hidden; }
.sp-month { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1.1rem; background: #f8fafc;
    border-bottom: 1px solid var(--border); font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #475569; }
.sp-month:not(:first-child) { border-top: 1px solid var(--border); }
.sp-month-sum { font-size: .75rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
.sp-month-sum b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-row { position: relative; display: grid; grid-template-columns: 3rem 2.4rem minmax(0, 1fr) 9rem 8.5rem 2.25rem; align-items: center; gap: .9rem;
    padding: .8rem 1.1rem; border-bottom: 1px solid #eef2f7; transition: background .15s; }
.sp-row:hover { background: #fafcff; }
.sp-row::before { content: ""; position: absolute; left: 0; top: .7rem; bottom: .7rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--c, #cbd5e1); opacity: .85; }
.sp-date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: .7rem;
    background: #fff; box-shadow: inset 0 0 0 1px var(--border); line-height: 1; }
.sp-date b { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.sp-date span { margin-top: .15rem; font-size: .6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sp-ico { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .7rem; color: var(--c, #64748b);
    background: color-mix(in srgb, var(--c, #64748b) 12%, white); }
.sp-ico svg { width: 1.15rem; height: 1.15rem; }
.sp-main { min-width: 0; }
.sp-title { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; font-size: .9rem; font-weight: 600; color: var(--ink); }
.sp-tag { padding: .05rem .5rem; border-radius: 9999px; font-size: .65rem; font-weight: 600; color: var(--c, #64748b);
    background: color-mix(in srgb, var(--c, #64748b) 10%, white); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #64748b) 22%, white); }
.sp-meta { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .2rem; font-size: .75rem; color: var(--muted); }
.sp-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.sp-meta svg { width: .8rem; height: .8rem; color: #94a3b8; }
.sp-comment { display: flex; align-items: flex-start; gap: .4rem; margin-top: .45rem; padding: .4rem .6rem; border-radius: .5rem; max-width: 46rem;
    font-size: .78rem; line-height: 1.45; color: #334155; background: #f8fafc; box-shadow: inset 0 0 0 1px #eef2f7; white-space: pre-line; }
.sp-comment svg { width: .85rem; height: .85rem; flex-shrink: 0; margin-top: .15rem; color: #94a3b8; }
.sp-qty { display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.sp-qty b { font-size: .8125rem; font-weight: 600; color: #334155; }
.sp-qty small { font-size: .7rem; font-weight: 500; color: var(--muted); }
.sp-qty span { font-size: .7rem; color: var(--muted); }
.sp-amt { text-align: right; font-size: .975rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-del { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; color: #cbd5e1; opacity: 0; transition: all .15s; }
.sp-row:hover .sp-del, .sp-del:focus-visible { opacity: 1; }
.sp-del:hover { color: #dc2626; background: #fef2f2; }
.sp-foot { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1.1rem; background: #f8fafc; font-size: .8125rem; color: var(--muted); }
.sp-foot b { color: var(--ink); font-size: .95rem; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
    .sp-row { grid-template-columns: 3rem minmax(0, 1fr) auto; }
    .sp-ico, .sp-del { display: none; }
    .sp-qty { grid-column: 2; align-items: flex-start; }
    .sp-amt { grid-column: 3; grid-row: 1; }
}
/* Spending form: numbers, rate, single-line comments */
.sp-num { text-align: right; font-variant-numeric: tabular-nums; }
.sp-amount-box { background: #f8fbff; border-color: #bfd3fe; }
.sp-amount-box .adorn-pre { background: #eff4ff; color: var(--brand); font-weight: 600; }
.sp-amount { font-weight: 700; color: var(--ink); }
.sp-submit { height: 2.6rem; }
.sp-comment { display: inline-flex; align-items: center; max-width: 100%; white-space: nowrap; padding: .2rem .55rem; margin-top: .35rem; }
.sp-comment span { overflow: hidden; text-overflow: ellipsis; }
.sp-comment svg { margin-top: 0; }
.sp-item-info::before { background: #d97706; }
.sp-item-info.is-contract::before { background: var(--brand); }
/* "0.4 bag / sq ft": the unit shown next to per-sq-ft quantities */
.per-sqft { display: inline-flex; width: 9.5rem; height: 2rem; }
.per-sqft .inp { border: 0 !important; background: #fffbeb; box-shadow: none !important; min-width: 0; text-align: right; }
.per-sqft:focus-within { border-color: var(--brand); }
.per-sqft .adorn-suf { padding: 0 .45rem; font-size: .68rem; white-space: nowrap; }
.lib-per { display: block; margin-top: .05rem; padding-right: .5rem; font-size: .65rem; color: #94a3b8; white-space: nowrap; }
.tbl input[name="estRate"].inp-sm { min-width: 6.75rem; }
/* Materials you buy: compact so it fits without a sideways scroll */
.mat-table th, .mat-table td { padding-left: .5rem; padding-right: .5rem; }
.mat-table th:first-child, .mat-table td:first-child { padding-left: 1rem; }
.mat-table th { font-size: .65rem; }
.mat-table select[name="suppliedBy"] { width: 6.5rem; }
.mat-table .per-sqft { width: 8.75rem; }
.mat-table input[name="estRate"].inp-sm { min-width: 6rem; width: 6.25rem; }
.mat-table input[name="leftOver"] { width: 4.5rem; }
.mat-table input[name="notes"] { min-width: 8rem; }
.mat-table td.w-44 { width: auto; }
.mat-table th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.mat-table th, .mat-table td { padding-left: .4rem; padding-right: .4rem; }
.mat-table .load-hint { white-space: normal; max-width: 6.5rem; margin-left: auto; line-height: 1.3; }
.mat-table .per-sqft { width: 8rem; }
.mat-table input[name="estRate"].inp-sm { min-width: 5.5rem; width: 5.5rem; }
.mat-table select[name="suppliedBy"] { width: 6rem; }
.mat-table input[name="notes"] { min-width: 6rem; }
.mat-table .load-edit input { width: 4rem; }
.mat-table .load-hint { white-space: nowrap; max-width: none; }

/* ---------- Project page ---------- */
.proj-hero { padding: 1.75rem 2rem; }
.proj-status { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .65rem; border-radius: 9999px; font-size: .75rem; font-weight: 700;
    color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.proj-status i { width: .5rem; height: .5rem; border-radius: 9999px; background: #94a3b8; box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.proj-status-planning i { background: #fbbf24; }
.proj-status-building i { background: #60a5fa; }
.proj-status-completed i { background: #34d399; }
.proj-chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .9rem; }
.proj-chips span { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: .55rem; font-size: .8rem; font-weight: 500;
    color: #dbe6fe; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); white-space: nowrap; }
.proj-chips svg { width: .95rem; height: .95rem; color: #93b4fd; flex-shrink: 0; }
.proj-btn-ghost { color: #fff; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.22); }
.proj-btn-ghost:hover { background: rgba(255,255,255,.16); }
.hero-bar { height: .3rem; margin-top: .55rem; border-radius: 9999px; background: rgba(255,255,255,.14); overflow: hidden; }
.hero-bar span { display: block; height: 100%; border-radius: 9999px; background: linear-gradient(90deg, #60a5fa, #a5f3fc); }

.proj-tabs { display: flex; gap: .3rem; padding: .3rem; margin-bottom: 1.5rem; overflow-x: auto; background: #fff; border: 1px solid var(--border);
    border-radius: .85rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.proj-tab { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1rem; border-radius: .6rem; font-size: .875rem; font-weight: 600;
    color: var(--muted); white-space: nowrap; transition: all .15s; }
.proj-tab svg { width: 1.05rem; height: 1.05rem; }
.proj-tab:hover { color: var(--ink); background: #f8fafc; }
.proj-tab[aria-current="page"] { color: #fff; background: linear-gradient(135deg, #1d43c0, #2554e0); box-shadow: 0 8px 18px -10px rgba(29,67,192,.9); }
.proj-tab-n { font-size: .6875rem; font-weight: 700; padding: .05rem .45rem; border-radius: 9999px; background: #f1f5f9; color: var(--muted); }
.proj-tab[aria-current="page"] .proj-tab-n { background: rgba(255,255,255,.2); color: #fff; }

.deal-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #f8fbff, #fff); }

.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem;
    border-radius: .85rem; background: #fff; border: 1px solid #fecaca; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.danger-zone h3 { font-size: .9rem; font-weight: 700; color: #b91c1c; }
.danger-zone p { font-size: .8rem; color: var(--muted); margin-top: .15rem; max-width: 42rem; }
.danger-btn { color: #b91c1c; background: #fff; box-shadow: inset 0 0 0 1px #fca5a5; }
.danger-btn:hover { color: #fff; background: #dc2626; box-shadow: none; }
@media (max-width: 640px) { .proj-hero { padding: 1.25rem; } }
.proj-tabs { scrollbar-width: none; }
.proj-tabs::-webkit-scrollbar { display: none; }

/* ---------- Suppliers & rate book ---------- */
.sp-history { display: flex; align-items: center; gap: .5rem; margin-top: -.5rem; padding: .5rem .8rem; border-radius: .6rem; font-size: .78rem; font-weight: 500;
    color: #065f46; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; }
.sp-history::before { content: "₨"; display: grid; place-items: center; flex-shrink: 0; width: 1.1rem; height: 1.1rem; border-radius: 9999px;
    font-size: .6rem; font-weight: 700; color: #fff; background: #10b981; }
.sp-history.hidden { display: none; }
[data-spend-payee] { color: #047857; }

.rate-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 34rem), 1fr)); }
.rate-card { background: #fff; border: 1px solid var(--border); border-radius: .9rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); overflow: hidden; }
.rate-head { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-bottom: 1px solid #eef2f7;
    background: linear-gradient(90deg, color-mix(in srgb, var(--c, #64748b) 7%, white), #fff); }
.rate-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.4rem; height: 2.4rem; border-radius: .7rem; color: var(--c, #64748b);
    background: color-mix(in srgb, var(--c, #64748b) 14%, white); }
.rate-ico svg { width: 1.15rem; height: 1.15rem; }
.rate-head h3 { font-size: .95rem; font-weight: 700; color: var(--ink); }
.rate-head h3 span { font-size: .75rem; font-weight: 500; color: var(--muted); }
.rate-head p { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.rate-best { display: flex; flex-direction: column; align-items: flex-end; padding: .35rem .7rem; border-radius: .6rem; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; text-align: right; }
.rate-best span { font-size: .6rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #047857; }
.rate-best b { font-size: 1rem; font-weight: 700; color: #065f46; font-variant-numeric: tabular-nums; }
.rate-best small { font-size: .68rem; color: #047857; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-table { width: 100%; font-size: .8125rem; }
.rate-table th { padding: .5rem .8rem; font-size: .62rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: #f8fafc; }
.rate-table td { padding: .55rem .8rem; border-top: 1px solid #f1f5f9; }
.rate-table tr.is-best td { background: #f6fef9; }
.rate-table td.num b { font-weight: 700; color: var(--ink); }
.rate-table small { color: var(--muted); font-size: .7rem; }
.rate-who { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--ink); }
.rate-who i { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 9999px; font-size: .6rem; font-style: normal; font-weight: 700; color: #fff; }
.rate-tag { display: inline-block; margin-left: .35rem; padding: 0 .4rem; border-radius: 9999px; font-size: .6rem; font-weight: 700; color: #047857; background: #d1fae5; vertical-align: middle; }
.rate-more { display: block; font-size: .65rem; font-weight: 600; color: #b45309; }
.sup-items { margin-top: .7rem; display: grid; gap: .3rem; }
.sup-items li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .78rem; color: #334155; }
.sup-items b { font-weight: 700; color: var(--ink); }
.sup-items small { color: var(--muted); font-size: .68rem; margin-left: .1rem; }

/* ---------- Tag list (what a supplier sells) ---------- */
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-height: 2.2rem; padding: .25rem .4rem; border: 1px solid var(--border-strong);
    border-radius: .5rem; background: #fff; transition: border-color .15s, box-shadow .15s; cursor: text; }
.tags:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.tags > svg { width: 1rem; height: 1rem; color: #94a3b8; flex-shrink: 0; margin: 0 .1rem; }
.tags [data-tags-list] { display: contents; }
.tag { display: inline-flex; align-items: center; gap: .15rem; padding: .1rem .2rem .1rem .55rem; border-radius: 9999px; font-size: .75rem; font-weight: 600;
    color: #1c389b; background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; white-space: nowrap; }
.tag button { display: grid; place-items: center; width: 1.1rem; height: 1.1rem; border-radius: 9999px; font-size: .85rem; line-height: 1; color: #6b86d8; }
.tag button:hover { color: #fff; background: #dc2626; }
.tags-input { flex: 1; min-width: 6rem; border: 0; outline: 0; background: transparent; font-size: .8125rem; padding: .2rem .25rem; }
.tags input[data-picker] { background-image: none; padding-right: .25rem; }
.sup-sells-label { margin: 1rem 0 .3rem; font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; }

/* ---------- Contracts total ---------- */
.ct-total { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 2rem; margin-top: 1rem; padding: .9rem 1.25rem; border-radius: .9rem;
    background: linear-gradient(135deg, #111c42, #1b2f6e); color: #dbe6fe; box-shadow: 0 14px 30px -18px rgba(17,28,66,.7); }
.ct-total-main { display: flex; flex-direction: column; }
.ct-total-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #93b4fd; }
.ct-total-label span { margin-left: .3rem; padding: 0 .4rem; border-radius: 9999px; background: rgba(255,255,255,.14); color: #fff; }
.ct-total-main b { font-size: 1.4rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ct-total-fig { display: flex; flex-direction: column; }
.ct-total-fig span { font-size: .7rem; font-weight: 600; color: #93b4fd; }
.ct-total-fig b { font-size: 1rem; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.ct-total-fig b.text-amber-700 { color: #fcd34d; }
.ct-total-fig b.text-emerald-700 { color: #6ee7b7; }
.ct-total-fig b.text-red-600 { color: #fca5a5; }
.ct-total-bar { flex: 1; min-width: 12rem; display: flex; align-items: center; gap: .75rem; }
.ct-total-bar .progress { flex: 1; background: rgba(255,255,255,.15); }
.ct-total-bar .progress > div { background: linear-gradient(90deg, #60a5fa, #a5f3fc); }
.ct-total-bar span { font-size: .75rem; font-weight: 600; color: #dbe6fe; white-space: nowrap; }

/* =====================================================================
   Dark theme: html.dark (set by the theme switch in the header; see _Layout)
   ===================================================================== */
html.dark {
    color-scheme: dark;
    --border: #3a4660;   /* soft dark theme: slate, not near-black */
    --border-strong: #4a5879;
    --muted: #94a3b8;
    --ink: #e5eaf5;
    --brand-ring: rgba(96, 140, 255, .35);
    --d-bg: #1c2433;
    --d-surface: #242e40;
    --d-surface-2: #202a3a;
    --d-surface-3: #2d384d;
    --d-input: #1f2838;
    --d-amber: rgba(245, 158, 11, .09);
    --d-amber-line: rgba(245, 158, 11, .35);
}
html.dark body { background: var(--d-bg) !important; color: var(--ink); }

/* Tailwind utilities used in the pages */
html.dark .bg-white { background-color: var(--d-surface) !important; }
html.dark .bg-slate-50, html.dark .hover\:bg-slate-50:hover { background-color: var(--d-surface-2) !important; }
html.dark .bg-slate-100 { background-color: var(--d-surface-3) !important; }
html.dark .text-slate-900, html.dark .text-slate-800 { color: var(--ink) !important; }
html.dark .text-slate-700, html.dark .text-slate-600 { color: #cbd5e1 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #7c8aa5 !important; }
html.dark .border-slate-100, html.dark .border-slate-200 { border-color: var(--border) !important; }
html.dark .bg-amber-50 { background-color: var(--d-amber) !important; }
html.dark .border-amber-300 { border-color: var(--d-amber-line) !important; }
html.dark .bg-brand-50, html.dark .hover\:bg-brand-50:hover { background-color: rgba(59, 110, 245, .15) !important; }
html.dark .bg-emerald-50 { background-color: rgba(16, 185, 129, .14) !important; }
html.dark .bg-indigo-50 { background-color: rgba(99, 102, 241, .16) !important; }
html.dark .bg-red-50 { background-color: rgba(239, 68, 68, .12) !important; }
html.dark .text-brand-700, html.dark .text-brand-600, html.dark .hover\:text-brand-700:hover { color: #93b4fd !important; }
html.dark .text-brand-900 { color: #c7d7fe !important; }
html.dark .text-emerald-700, html.dark .text-emerald-600 { color: #34d399 !important; }
html.dark .text-amber-700, html.dark .text-amber-600 { color: #fbbf24 !important; }
html.dark .text-red-600 { color: #f87171 !important; }
html.dark .text-indigo-600 { color: #a5b4fc !important; }
/* the white buttons on the hero banners stay light */
html.dark .hero .bg-white { background-color: #fff !important; }
html.dark .hero .text-brand-900 { color: #1b2f6e !important; }

/* Surfaces */
html.dark .card, html.dark .kpi, html.dark .ccard, html.dark .pcard, html.dark .rate-card, html.dark .danger-zone,
html.dark .ct-list.ct-rows, html.dark .lib-tabs, html.dark .proj-tabs, html.dark .cat-chip, html.dark .search,
html.dark .crumb-current, html.dark .crumb-home a, html.dark .view-toggle button[aria-pressed="true"], html.dark .stat-chip {
    background: var(--d-surface); border-color: var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
html.dark a.card:hover, html.dark .pcard:hover { border-color: var(--border-strong); box-shadow: 0 10px 24px -12px rgba(0,0,0,.6); }
html.dark .crumbbar { background: rgba(28, 36, 51, .85); border-color: var(--border); }
html.dark .crumb-link { color: #94a3b8; }
html.dark .crumb-link:hover { background: var(--d-surface-3); color: var(--ink); }
html.dark footer { background: var(--d-surface-2) !important; border-color: var(--border) !important; }
html.dark .card-title, html.dark .kpi-value, html.dark .ccard-name, html.dark .pcard h3 { color: var(--ink); }
html.dark .section-icon { background: rgba(59,110,245,.15); color: #93b4fd; box-shadow: inset 0 0 0 1px rgba(96,140,255,.25); }
html.dark .pcard-new { border-color: var(--border-strong); color: var(--ink); }
html.dark .pcard-new:hover { background: rgba(59,110,245,.08); border-color: #3b6ef5; }

/* Inputs */
html.dark .inp, html.dark .adorn, html.dark .ccard-field, html.dark .tags, html.dark .load-edit {
    background-color: var(--d-input); border-color: var(--border-strong); color: var(--ink);
}
html.dark .inp::placeholder, html.dark input::placeholder, html.dark textarea::placeholder { color: #5f6e89; }
html.dark .inp:disabled { background: var(--d-surface-2); color: #64748b; }
html.dark .inp.bg-amber-50, html.dark .adorn .inp.bg-amber-50, html.dark .per-sqft .inp { background-color: var(--d-amber) !important; color: #fde68a; }
html.dark .adorn-pre, html.dark .adorn-suf { background: var(--d-surface-2); border-color: var(--border); color: #94a3b8; }
html.dark .ccard-field input, html.dark .ccard-name, html.dark .ccard-notes, html.dark .tags-input, html.dark .lib-note, html.dark .load-edit input { color: var(--ink); }
html.dark .ccard-name:focus { background: var(--d-input); }
html.dark select.inp option { background: var(--d-surface); color: var(--ink); }
html.dark .seg, html.dark .view-toggle, html.dark .lib-tab-n, html.dark .proj-tab-n, html.dark .cat-n { background: var(--d-surface-2); border-color: var(--border); }
html.dark .seg input:checked + span { background: var(--d-surface-3); color: #93b4fd; }
html.dark .switch-track { background: #4a5879; }
html.dark .btn-light { background: var(--d-surface); border-color: var(--border-strong); color: var(--ink); }
html.dark .btn-light:hover { background: var(--d-surface-3); }
html.dark .chip { background: var(--d-surface); border-color: var(--border-strong); color: #cbd5e1; }
html.dark .chip:hover { background: rgba(59,110,245,.15); color: #c7d7fe; }
html.dark .lib-tabs button:hover, html.dark .proj-tab:hover { background: var(--d-surface-3); color: var(--ink); }
html.dark .cat-chip:hover { border-color: var(--border-strong); color: var(--ink); }
html.dark .cat-chip.is-on { background: #3b6ef5; }
html.dark .cat-dot { box-shadow: 0 0 0 2px var(--d-surface), 0 0 0 3px rgba(255,255,255,.08); }

/* Tables */
html.dark .tbl th, html.dark .tbl tfoot td, html.dark .ct-rows .ct-head, html.dark .rate-table th { background: var(--d-surface-2); color: #94a3b8; border-color: var(--border); }
html.dark .tbl td { border-color: var(--border); }
html.dark .tbl tbody tr:hover td { background: var(--d-surface-3); }
html.dark .tbl tr.row-total td { background: var(--d-surface-2); }
html.dark .tbl tr.cat-row td { background: linear-gradient(90deg, var(--d-surface-2), var(--d-surface)); color: var(--ink); border-color: var(--border); }
html.dark .lib-table tr.lib-row:hover td, html.dark .ct-rows .ccard:hover, html.dark .sp-row:hover { background: var(--d-surface-3); }
html.dark .lib-table tr.lib-row:focus-within td, html.dark .ct-rows .ccard:focus-within { background: #1a2748; }
html.dark .lib-table .inp, html.dark .lib-table .adorn, html.dark .ct-rows .inp, html.dark .ct-rows .adorn, html.dark .ct-rows .ccard-field { background-color: transparent; border-color: transparent; }
html.dark .lib-table tr.lib-row:hover .inp, html.dark .lib-table tr.lib-row:hover .adorn,
html.dark .ct-rows .ccard:hover :is(.ccard-field, .inp, .adorn) { background-color: var(--d-input); border-color: var(--border-strong); }
html.dark .lib-table .lib-edit { color: #fcd34d; }
html.dark .ct-rows .ccard { border-color: var(--border); }
html.dark .rate-table td { border-color: var(--border); }
html.dark .rate-table tr.is-best td { background: rgba(16,185,129,.08); }
html.dark .rate-head { border-color: var(--border); background: linear-gradient(90deg, color-mix(in srgb, var(--c, #64748b) 14%, var(--d-surface)), var(--d-surface)); }
html.dark .rate-best, html.dark .lib-badge-learned, html.dark .call-btn { background: rgba(16,185,129,.14); box-shadow: inset 0 0 0 1px rgba(16,185,129,.35); color: #6ee7b7; }
html.dark .rate-best b, html.dark .rate-best span, html.dark .rate-best small { color: #6ee7b7; }
html.dark .rate-tag { background: rgba(16,185,129,.2); color: #6ee7b7; }

/* Cards & blocks inside */
html.dark .ccard-money, html.dark .lib-est, html.dark .calc-line { background: var(--d-surface-2); box-shadow: inset 0 0 0 1px var(--border); border-color: var(--border); }
html.dark .ccard-notes { border-color: var(--border); }
html.dark .tag { background: rgba(59,110,245,.16); color: #c7d7fe; box-shadow: inset 0 0 0 1px rgba(96,140,255,.35); }
html.dark .area-pill { background: rgba(245,158,11,.12); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245,158,11,.35); }
html.dark .load-chip { background: rgba(245,158,11,.12); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245,158,11,.35); }
html.dark .load-chip.load-clear { background: var(--d-surface-2); color: #94a3b8; box-shadow: inset 0 0 0 1px var(--border); }
html.dark .floor-num, html.dark .picker-ico { background: var(--d-surface-3); color: #94a3b8; }
html.dark .floor-del:hover:not(:disabled), html.dark .sp-del:hover { background: rgba(239,68,68,.15); }
html.dark .below-chip span { border-color: var(--border-strong); }
html.dark .progress, html.dark .seg-bar { background: var(--d-surface-3); }
html.dark .badge-planning { background: rgba(245,158,11,.15); color: #fcd34d; }
html.dark .badge-building { background: rgba(59,110,245,.18); color: #93b4fd; }
html.dark .badge-completed { background: rgba(16,185,129,.15); color: #6ee7b7; }
html.dark .alert-success { background: rgba(16,185,129,.12); color: #6ee7b7; border-color: rgba(16,185,129,.35); }
html.dark .alert-error { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.35); }
html.dark .alert-warn { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.35); }
html.dark .rating { background: var(--d-surface-3); }

/* Spending log */
html.dark .sp-form-head, html.dark .deal-head, html.dark .modal-head { background: linear-gradient(180deg, var(--d-surface-3), var(--d-surface)); border-color: var(--border); }
html.dark .sp-month, html.dark .sp-foot { background: var(--d-surface-2); border-color: var(--border); color: #94a3b8; }
html.dark .sp-row { border-color: var(--border); }
html.dark .sp-date { background: var(--d-surface-2); box-shadow: inset 0 0 0 1px var(--border); }
html.dark .sp-comment { background: var(--d-surface-2); color: #cbd5e1; box-shadow: inset 0 0 0 1px var(--border); }
html.dark .sp-qty b { color: #cbd5e1; }
html.dark .sp-amount-box { background: rgba(59,110,245,.08); border-color: rgba(96,140,255,.4); }
html.dark .sp-amount-box .adorn-pre { background: rgba(59,110,245,.15); color: #93b4fd; }
html.dark .sp-item-info { background: rgba(245,158,11,.1); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245,158,11,.3); }
html.dark .sp-item-info.is-contract { background: rgba(59,110,245,.12); color: #c7d7fe; box-shadow: inset 0 0 0 1px rgba(96,140,255,.35); }
html.dark .sp-history { background: rgba(16,185,129,.1); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(16,185,129,.3); }
html.dark .sup-items li { color: #cbd5e1; }

/* Picker, dialogs, toasts */
html.dark .picker { background: rgba(17, 26, 46, .98); border-color: var(--border-strong); box-shadow: 0 18px 40px -12px rgba(0,0,0,.7); }
html.dark .picker-opt.is-active { background: var(--d-surface-3); }
html.dark .picker-opt.is-active .picker-name { color: #93b4fd; }
html.dark .picker-name { color: var(--ink); }
html.dark .picker-phone { background: var(--d-surface-3); color: #94a3b8; }
html.dark .picker-foot { background: var(--d-surface-2); border-color: var(--border); color: #93b4fd; }
html.dark .picker mark { background: rgba(250, 204, 21, .3); color: #fef08a; }
html.dark .picker-plus { background: transparent; }
html.dark .picker-av { box-shadow: 0 0 0 2px var(--d-surface), 0 0 0 3px var(--border); }
html.dark .picker-item-ico, html.dark .sp-ico, html.dark .rate-ico { background: color-mix(in srgb, var(--c, #64748b) 22%, var(--d-surface)); box-shadow: none; }
html.dark .sp-tag { background: color-mix(in srgb, var(--c, #64748b) 18%, var(--d-surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #64748b) 40%, var(--d-surface)); filter: brightness(1.3); }
html.dark dialog.modal { background: var(--d-surface); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(0,0,0,.8), 0 0 0 1px var(--border); }
html.dark dialog.modal::backdrop { background: rgba(2, 6, 16, .65); }
html.dark .modal-foot { background: var(--d-surface-2); border-color: var(--border); }
html.dark .modal-est { background: linear-gradient(135deg, rgba(59,110,245,.15), var(--d-surface-2)); box-shadow: inset 0 0 0 1px rgba(96,140,255,.3); }
html.dark .modal-est b { color: #93b4fd; }
html.dark .modal-x:hover { background: var(--d-surface-3); color: var(--ink); }
html.dark .toast { background: rgba(17, 26, 46, .97); box-shadow: 0 20px 40px -16px rgba(0,0,0,.8), 0 0 0 1px var(--border-strong); }
html.dark .toast-title { color: var(--ink); }
html.dark .toast-msg { color: #cbd5e1; }
html.dark .toast-x:hover { background: var(--d-surface-3); color: var(--ink); }
html.dark .toast-saved { background: rgba(30, 44, 80, .97); }
html.dark .danger-zone { border-color: rgba(239,68,68,.4); }
html.dark .danger-zone h3 { color: #f87171; }
html.dark .danger-btn { background: transparent; color: #f87171; box-shadow: inset 0 0 0 1px rgba(239,68,68,.5); }

/* ---------- Theme switch (header) ---------- */
.theme-btn { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .6rem; color: #c7d7fe; background: rgba(255,255,255,.06);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: all .15s; flex-shrink: 0; }
.theme-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.theme-btn svg { width: 1.1rem; height: 1.1rem; }
.theme-btn [data-icon] { display: none; }
html[data-theme="light"] .theme-btn [data-icon="light"],
html[data-theme="dark"] .theme-btn [data-icon="dark"],
html[data-theme="system"] .theme-btn [data-icon="system"],
html:not([data-theme]) .theme-btn [data-icon="system"] { display: block; }
/* dark: text that uses fixed dark greys in the light theme */
html.dark .field-label, html.dark .pbar-name, html.dark .cat-chip, html.dark .sp-month, html.dark .stat-chip,
html.dark .below-chip span, html.dark .hero-step { color: #cbd5e1; }
html.dark .pbar-zero { background: var(--border-strong); }
html.dark .tbl td, html.dark .tbl { color: var(--ink); }

/* =====================================================================
   Sign-in pages (_AuthLayout)
   ===================================================================== */
.auth-body { min-height: 100vh; background: #f4f7fc; color: var(--ink); }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand { position: relative; overflow: hidden; padding: 3rem;
    background: radial-gradient(900px 400px at 0% 0%, rgba(59,110,245,.45), transparent 60%), linear-gradient(150deg, #0b1534 0%, #1b2f6e 55%, #1d43c0 100%); }
.auth-brand::before { content: ""; position: absolute; inset: 0; pointer-events: none;
    background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 30px 30px; mask-image: linear-gradient(160deg, transparent 10%, #000 70%); -webkit-mask-image: linear-gradient(160deg, transparent 10%, #000 70%); }
.auth-brand-inner { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; max-width: 30rem; }
.auth-pitch { margin: auto 0; padding: 3rem 0; }
.auth-pitch h2 { font-size: 2.2rem; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; color: #fff; }
.auth-pitch ul { margin-top: 1.75rem; display: grid; gap: .8rem; }
.auth-pitch li { display: flex; align-items: center; gap: .7rem; color: #c7d7fe; font-size: .95rem; }
.auth-pitch li i { width: 1.4rem; height: 1.4rem; flex-shrink: 0; border-radius: 9999px; background: rgba(16,185,129,.2); box-shadow: inset 0 0 0 1px rgba(110,231,183,.5);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236ee7b7'%3E%3Cpath d='M16.7 5.3a1 1 0 0 1 0 1.4l-8 8a1 1 0 0 1-1.4 0l-4-4a1 1 0 1 1 1.4-1.4L8 12.6l7.3-7.3a1 1 0 0 1 1.4 0Z'/%3E%3C/svg%3E");
    background-size: .85rem; background-position: center; background-repeat: no-repeat; }
.auth-foot { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: #93b4fd; }
.auth-main { position: relative; display: grid; place-items: center; padding: 3rem 1.5rem; }
.auth-theme { position: absolute; top: 1.25rem; right: 1.25rem; color: #64748b; background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.auth-theme:hover { color: var(--ink); background: #f1f5f9; }
.auth-card { width: min(26rem, 100%); }
.auth-head { margin-bottom: 1.5rem; }
.auth-head h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.auth-head p { margin-top: .35rem; font-size: .9rem; color: var(--muted); }
.auth-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: 1rem; border-radius: .9rem; color: var(--brand); background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; }
.auth-icon svg { width: 1.5rem; height: 1.5rem; }
.auth-form { display: grid; gap: 1.1rem; }
.auth-field { display: block; }
.auth-field > span, .auth-label { display: block; margin-bottom: .4rem; font-size: .8125rem; font-weight: 600; color: #334155; }
.auth-input { display: flex; align-items: center; gap: .6rem; height: 2.9rem; padding: 0 .85rem; border-radius: .7rem; background: #fff; border: 1px solid var(--border-strong);
    transition: border-color .15s, box-shadow .15s; }
.auth-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.auth-input > svg { width: 1.05rem; height: 1.05rem; color: #94a3b8; flex-shrink: 0; }
.auth-input input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: .95rem; color: var(--ink); }
.auth-eye { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; color: #94a3b8; }
.auth-eye svg { width: 1.15rem; height: 1.15rem; }
.auth-eye:hover, .auth-eye.is-on { color: var(--brand); background: #eff4ff; }
.auth-hint { display: block; margin-top: .35rem; font-size: .72rem; color: var(--muted); }
.auth-submit { height: 2.95rem; justify-content: center; font-size: .95rem; border-radius: .7rem; margin-top: .3rem; box-shadow: 0 10px 22px -12px rgba(29,67,192,.9); }
.auth-note { text-align: center; font-size: .8rem; color: var(--muted); }
.auth-error { display: flex; align-items: flex-start; gap: .55rem; margin-bottom: 1.1rem; padding: .7rem .85rem; border-radius: .7rem; font-size: .85rem;
    color: #b91c1c; background: #fef2f2; box-shadow: inset 0 0 0 1px #fecaca; }
.auth-error svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; margin-top: .05rem; }
.captcha-row { display: flex; align-items: center; gap: .6rem; }
.captcha-img { border-radius: .6rem; box-shadow: inset 0 0 0 1px var(--border), 0 1px 2px rgba(15,23,42,.06); user-select: none; image-rendering: pixelated; background: #eef2ff; }
.captcha-refresh { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: .6rem; color: var(--brand); background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; transition: transform .3s; }
.captcha-refresh:hover { transform: rotate(-90deg); }
.captcha-refresh svg { width: 1.2rem; height: 1.2rem; }
.auth-step { display: flex; align-items: center; gap: .4rem; margin-bottom: 1.25rem; }
.auth-step span { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 9999px; font-size: .75rem; font-weight: 700; color: var(--muted); background: #e2e8f0; }
.auth-step span.is-done { color: #fff; background: #10b981; }
.auth-step span.is-on { color: #fff; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.auth-step i { width: 2.5rem; height: 2px; background: #10b981; }
.otp-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.otp-boxes input[type=text] { height: 3.4rem; text-align: center; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; border-radius: .7rem;
    background: #fff; border: 1px solid var(--border-strong); color: var(--ink); outline: 0; transition: border-color .15s, box-shadow .15s; }
.otp-boxes input[type=text]:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
.otp-qr { display: flex; gap: 1.1rem; align-items: center; padding: 1rem; border-radius: .9rem; background: #fff; border: 1px solid var(--border); }
.otp-qr-code { flex-shrink: 0; width: 9.5rem; height: 9.5rem; padding: .3rem; border-radius: .6rem; background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.otp-qr-code svg { width: 100%; height: 100%; display: block; }
.otp-qr-text ol { list-style: decimal; padding-left: 1.1rem; display: grid; gap: .3rem; font-size: .8rem; color: #475569; }
.otp-key { margin-top: .75rem; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: .72rem; color: var(--muted); }
.otp-key code { font-size: .78rem; font-weight: 700; letter-spacing: .06em; color: var(--ink); background: #f1f5f9; padding: .15rem .45rem; border-radius: .35rem; }
.otp-copy { font-size: .72rem; font-weight: 600; color: var(--brand); }
@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { padding: 1.5rem; }
    .auth-pitch, .auth-foot { display: none; }
}
@media (max-width: 480px) { .otp-qr { flex-direction: column; align-items: flex-start; } }

/* ---------- Header: user menu ---------- */
.user-menu { position: relative; flex-shrink: 0; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border-radius: .7rem; cursor: pointer;
    color: #dbe6fe; transition: background .15s; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: rgba(255,255,255,.1); }
.user-av { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9999px; font-size: .72rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #3b6ef5, #8b5cf6); box-shadow: 0 0 0 2px rgba(255,255,255,.18); }
.user-who { display: flex; flex-direction: column; line-height: 1.15; }
.user-who b { font-size: .8rem; font-weight: 600; color: #fff; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-who small { font-size: .65rem; color: #93b4fd; }
.user-pop { position: absolute; right: 0; top: calc(100% + .5rem); z-index: 70; width: 15rem; padding: .35rem; border-radius: .8rem; background: #fff; color: var(--ink);
    border: 1px solid var(--border); box-shadow: 0 18px 40px -12px rgba(15,23,42,.35); animation: picker-in .14s ease-out; }
.user-pop-head { padding: .6rem .7rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.user-pop-head b { display: block; font-size: .85rem; }
.user-pop-head span { font-size: .72rem; color: var(--muted); }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: .55rem; font-size: .84rem; font-weight: 500; color: #334155; text-align: left; }
.user-pop a:hover, .user-pop button:hover { background: #f1f5f9; color: var(--ink); }
.user-pop svg { width: 1rem; height: 1rem; color: #94a3b8; }
.user-pop form button { color: #b91c1c; }
.user-pop form button svg { color: #f87171; }
@media (max-width: 760px) { .user-who { display: none; } }

/* ---------- Access chips, banners ---------- */
.lvl { display: inline-flex; align-items: center; padding: .1rem .5rem; border-radius: 9999px; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.lvl-edit { color: #047857; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; }
.lvl-view { color: #1c389b; background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; }
.lvl-none { color: #64748b; background: #f1f5f9; box-shadow: inset 0 0 0 1px #e2e8f0; }
.ro-banner { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; padding: .65rem .9rem; border-radius: .75rem; font-size: .85rem;
    color: #1c389b; background: #eff4ff; box-shadow: inset 0 0 0 1px #bfd3fe; }
.ro-banner svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.ro-off { opacity: .75; cursor: not-allowed !important; }
.acc-av { display: grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 1.2rem; font-size: 1.4rem; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #3b6ef5, #8b5cf6); box-shadow: 0 0 0 4px rgba(255,255,255,.15); }
.acc-list { display: grid; gap: .6rem; }
.acc-list li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-bottom: .6rem; border-bottom: 1px dashed var(--border); font-size: .875rem; }
.acc-list li:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------- Admin: users ---------- */
.user-table { overflow: hidden; }
.user-row { display: grid; grid-template-columns: minmax(14rem, 1.4fr) 6rem minmax(16rem, 2fr) minmax(11rem, 1fr) 8rem 9rem; align-items: center; gap: 1rem;
    padding: .85rem 1.1rem; border-bottom: 1px solid #eef2f7; }
.user-row:last-of-type { border-bottom: 0; }
.user-row:not(.user-row-head):hover { background: #fafcff; }
.user-row-head { padding-top: .6rem; padding-bottom: .6rem; background: #f8fafc; font-size: .65rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.user-row.is-off { opacity: .65; }
.user-who-cell { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.user-who-cell b { display: block; font-size: .9rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-who-cell span { font-size: .75rem; color: var(--muted); }
.user-who-cell .you { margin-left: .3rem; padding: 0 .4rem; border-radius: 9999px; font-size: .62rem; font-style: normal; font-weight: 700; color: #fff; background: var(--brand); vertical-align: middle; }
.role { display: inline-flex; padding: .15rem .6rem; border-radius: .45rem; font-size: .72rem; font-weight: 700; }
.role-admin { color: #fff; background: linear-gradient(135deg, #1d43c0, #8b5cf6); }
.role-user { color: #334155; background: #f1f5f9; box-shadow: inset 0 0 0 1px #e2e8f0; }
.acc-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.user-signin { display: flex; flex-direction: column; gap: .2rem; }
.user-signin small { font-size: .7rem; color: var(--muted); }
.otp { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 600; }
.otp::before { content: ""; width: .5rem; height: .5rem; border-radius: 9999px; background: currentColor; }
.otp-on { color: #047857; } .otp-wait { color: #b45309; } .otp-off { color: #64748b; }
.state { display: inline-flex; padding: .15rem .55rem; border-radius: 9999px; font-size: .72rem; font-weight: 700; }
.state-on { color: #047857; background: #ecfdf5; } .state-off { color: #64748b; background: #f1f5f9; } .state-locked { color: #b91c1c; background: #fef2f2; }
.user-actions { display: flex; align-items: center; justify-content: flex-end; gap: .35rem; }
.row-menu { position: relative; }
.row-menu summary { list-style: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; color: #64748b; cursor: pointer; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu summary:hover, .row-menu[open] summary { background: #f1f5f9; color: var(--ink); }
.row-pop { position: absolute; right: 0; top: calc(100% + .3rem); z-index: 40; width: 13rem; padding: .3rem; border-radius: .7rem; background: #fff;
    border: 1px solid var(--border); box-shadow: 0 16px 34px -12px rgba(15,23,42,.35); }
.row-pop button { display: block; width: 100%; padding: .5rem .65rem; border-radius: .5rem; text-align: left; font-size: .82rem; font-weight: 500; color: #334155; }
.row-pop button:hover { background: #f1f5f9; }
.row-pop button.is-danger { color: #b91c1c; }
.row-pop button.is-danger:hover { background: #fef2f2; }
.access-grid { display: grid; gap: .5rem; }
.access-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .84rem; font-weight: 500; }
.seg-sm span { padding: .25rem .6rem; font-size: .75rem; }
.admin-note { padding: .6rem .8rem; border-radius: .6rem; font-size: .8rem; color: #5b21b6; background: #f5f3ff; box-shadow: inset 0 0 0 1px #ddd6fe; }
@media (max-width: 1100px) {
    .user-row { grid-template-columns: 1fr auto; }
    .user-row > :nth-child(2), .user-row > :nth-child(4), .user-row > :nth-child(5) { display: none; }
    .user-row > .acc-chips { grid-column: 1 / -1; }
    .user-row-head { display: none; }
}

/* ---------- Dark theme for the above ---------- */
html.dark .auth-body { background: var(--d-bg); }
html.dark .auth-theme { background: var(--d-surface); color: #94a3b8; box-shadow: inset 0 0 0 1px var(--border); }
html.dark .auth-field > span, html.dark .auth-label { color: #cbd5e1; }
html.dark .auth-input, html.dark .otp-boxes input[type=text] { background: var(--d-input); border-color: var(--border-strong); }
html.dark .auth-icon, html.dark .captcha-refresh, html.dark .auth-eye:hover, html.dark .auth-eye.is-on { background: rgba(59,110,245,.15); box-shadow: inset 0 0 0 1px rgba(96,140,255,.35); color: #93b4fd; }
html.dark .auth-error { background: rgba(239,68,68,.12); color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(239,68,68,.35); }
html.dark .auth-step span { background: var(--d-surface-3); }
html.dark .otp-qr { background: var(--d-surface); border-color: var(--border); }
html.dark .otp-qr-text ol { color: #cbd5e1; }
html.dark .otp-key code { background: var(--d-surface-3); }
html.dark .user-pop, html.dark .row-pop { background: var(--d-surface); border-color: var(--border-strong); box-shadow: 0 18px 40px -12px rgba(0,0,0,.7); }
html.dark .user-pop a, html.dark .user-pop button, html.dark .row-pop button { color: #cbd5e1; }
html.dark .user-pop a:hover, html.dark .user-pop button:hover, html.dark .row-pop button:hover, html.dark .row-menu summary:hover, html.dark .row-menu[open] summary { background: var(--d-surface-3); color: var(--ink); }
html.dark .user-pop-head { border-color: var(--border); }
html.dark .user-pop form button, html.dark .row-pop button.is-danger { color: #f87171; }
html.dark .lvl-edit, html.dark .state-on { background: rgba(16,185,129,.14); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(16,185,129,.35); }
html.dark .lvl-view, html.dark .ro-banner { background: rgba(59,110,245,.14); color: #c7d7fe; box-shadow: inset 0 0 0 1px rgba(96,140,255,.35); }
html.dark .lvl-none, html.dark .state-off, html.dark .role-user { background: var(--d-surface-3); color: #94a3b8; box-shadow: inset 0 0 0 1px var(--border); }
html.dark .state-locked { background: rgba(239,68,68,.14); color: #fca5a5; }
html.dark .user-row { border-color: var(--border); }
html.dark .user-row:not(.user-row-head):hover { background: var(--d-surface-3); }
html.dark .user-row-head { background: var(--d-surface-2); }
html.dark .admin-note { background: rgba(139,92,246,.14); color: #ddd6fe; box-shadow: inset 0 0 0 1px rgba(139,92,246,.35); }
html.dark .otp-on { color: #34d399; } html.dark .otp-wait { color: #fbbf24; }
.user-who-cell .avatar { color: #fff; font-size: .78rem; }
/* Code boxes shrink to the card (text inputs are wide by default). */
.otp-boxes input[type=text] { width: 100%; min-width: 0; padding: 0; }
.otp-boxes { max-width: 24rem; }
.auth-card, .auth-form, .auth-form > * { min-width: 0; }

/* =====================================================================
   Project timeline (Gantt)
   ===================================================================== */
.tl-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.tl-kpis .kpi-value { font-size: 1.25rem; }
.tl-kpi-late { border-color: #fecaca; background: linear-gradient(180deg, #fff, #fef2f2); }
.tl-kpi-late .kpi-value { color: #dc2626; }
@media (max-width: 1100px) { .tl-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tl-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }

.gantt { --day: 12px; --left-w: 300px; --row-h: 3.6rem; --grid: #eef2f7; overflow: hidden; margin-bottom: 1.5rem; }
.g-scroll { overflow-x: auto; overflow-y: hidden; }
.g-inner { position: relative; width: max-content; min-width: 100%; }
.g-head, .g-row { display: grid; grid-template-columns: var(--left-w) calc(var(--day) * var(--days)); }
.g-head { position: relative; height: 2.6rem; background: #f8fafc; border-bottom: 1px solid var(--border); }
.g-left { position: sticky; left: 0; z-index: 3; background: #fff; border-right: 1px solid var(--border); }
.g-left-head { display: flex; align-items: center; padding: 0 1rem; background: #f8fafc; font-size: .65rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.g-track { position: relative; height: 100%; }
.g-months .g-month { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; gap: .3rem; padding-left: .5rem; font-size: .72rem; color: var(--muted);
    border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.g-months .g-month b { color: var(--ink); font-weight: 700; }
.g-today-label { position: absolute; bottom: 2px; transform: translateX(-50%); padding: 0 .35rem; border-radius: .3rem; font-size: .6rem; font-weight: 700; color: #fff; background: #ef4444; z-index: 2; }
.g-body { position: relative; }
.g-body .g-track { background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(var(--day) * 7 - 1px), var(--grid) calc(var(--day) * 7 - 1px), var(--grid) calc(var(--day) * 7)); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ef4444; opacity: .7; z-index: 2; pointer-events: none; }
.g-links { position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; overflow: visible; }
.g-links path { fill: none; stroke: #94a3b8; stroke-width: 1.4; }
.g-links path.g-arrow { fill: #94a3b8; stroke: none; }

.g-row { height: var(--row-h); border-bottom: 1px solid #f1f5f9; }
.g-row:last-child { border-bottom: 0; }
.g-row:hover .g-left, .g-row:hover .g-track { background-color: #fafcff; }
button.g-left { display: flex; align-items: center; gap: .6rem; width: 100%; padding: 0 .8rem 0 1rem; text-align: left; cursor: pointer; }
button.g-left:hover .g-name b { color: var(--brand); }
.g-dot { width: .7rem; height: .7rem; flex-shrink: 0; border-radius: .2rem; background: var(--c); }
.g-name { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.g-name b { font-size: .84rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-name small { font-size: .68rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-name .g-after { margin-left: .25rem; color: #94a3b8; }
.g-name .g-money { color: #64748b; }
.g-status { flex-shrink: 0; padding: .1rem .45rem; border-radius: 9999px; font-size: .62rem; font-weight: 700; white-space: nowrap; color: #64748b; background: #f1f5f9; }
.g-status-inprogress { color: #1c389b; background: #eff4ff; }
.g-status-done { color: #047857; background: #ecfdf5; }
.g-status-onhold { color: #b45309; background: #fffbeb; }
.g-status.is-late { color: #b91c1c; background: #fef2f2; }

.g-bar { position: absolute; top: 50%; height: 1.65rem; transform: translateY(-50%); z-index: 2; border-radius: .45rem; cursor: grab; touch-action: none; user-select: none;
    background: color-mix(in srgb, var(--c) 22%, white); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 70%, white); overflow: hidden;
    transition: box-shadow .15s, filter .15s; }
.g-bar:hover { box-shadow: inset 0 0 0 1.5px var(--c), 0 6px 14px -8px color-mix(in srgb, var(--c) 80%, black); }
.g-bar.is-dragging { cursor: grabbing; z-index: 5; box-shadow: inset 0 0 0 2px var(--c), 0 10px 20px -10px rgba(15,23,42,.5); }
.g-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); opacity: .9; }
.g-bar.is-done { background: var(--c); }
.g-bar.is-onhold { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--c) 30%, white) 6px 12px); }
.g-bar.is-late { box-shadow: inset 0 0 0 2px #ef4444; }
.g-label { position: relative; z-index: 1; display: block; padding: 0 .55rem; font-size: .7rem; font-weight: 600; line-height: 1.65rem; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-bar.is-done .g-label, .g-bar.is-inprogress .g-label { color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.g-check { position: absolute; right: .9rem; top: 50%; width: .9rem; height: .9rem; transform: translateY(-50%); color: #fff; z-index: 1; }
.g-handle { position: absolute; right: 0; top: 0; bottom: 0; width: .55rem; cursor: ew-resize; z-index: 2; }
.g-handle::after { content: ""; position: absolute; right: .2rem; top: .45rem; bottom: .45rem; width: 2px; border-radius: 2px; background: rgba(15,23,42,.25); opacity: 0; transition: opacity .15s; }
.g-bar:hover .g-handle::after { opacity: 1; }
.g-days { position: absolute; top: 50%; transform: translateY(-50%); font-size: .65rem; font-weight: 600; color: #94a3b8; white-space: nowrap; pointer-events: none; }
[data-readonly="true"] .g-bar { cursor: default; }
[data-readonly="true"] .g-handle { display: none; }
.g-tooltip { position: fixed; z-index: 80; padding: .3rem .55rem; border-radius: .4rem; font-size: .72rem; font-weight: 600; color: #fff; background: #0f172a; pointer-events: none; }
.g-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: .7rem 1rem; border-top: 1px solid var(--border); background: #f8fafc; font-size: .72rem; color: var(--muted); }
.g-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.lg { display: inline-block; width: 1.4rem; height: .65rem; border-radius: .2rem; }
.lg-plan { background: #dbe6fe; box-shadow: inset 0 0 0 1.5px #7da2f7; }
.lg-prog { background: linear-gradient(90deg, #3b6ef5 55%, #dbe6fe 55%); box-shadow: inset 0 0 0 1.5px #7da2f7; }
.lg-done { background: #3b6ef5; }
.lg-late { background: #dbe6fe; box-shadow: inset 0 0 0 2px #ef4444; }
.lg-link { height: 2px; background: #94a3b8; border-radius: 0; }
.lg-today { width: 2px; height: .9rem; background: #ef4444; border-radius: 0; }
@media (max-width: 760px) { .gantt { --left-w: 190px; } .g-status { display: none; } }

/* Empty state */
.tl-empty { padding: 3rem 2rem; text-align: center; }
.tl-empty h2 { font-size: 1.35rem; font-weight: 700; color: var(--ink); margin-top: 1.5rem; }
.tl-empty p { max-width: 38rem; margin: .5rem auto 0; font-size: .9rem; color: var(--muted); }
.tl-empty-art { position: relative; width: min(30rem, 100%); height: 6.5rem; margin: 0 auto; }
.tl-empty-art span { position: absolute; left: var(--l); width: var(--w); height: .9rem; border-radius: .3rem; background: var(--c); opacity: .85; }
.tl-empty-art span:nth-child(1) { top: 0; } .tl-empty-art span:nth-child(2) { top: 1.35rem; } .tl-empty-art span:nth-child(3) { top: 2.7rem; }
.tl-empty-art span:nth-child(4) { top: 4.05rem; } .tl-empty-art span:nth-child(5) { top: 5.4rem; }
.tl-empty-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem; margin-top: 1.5rem; }
.tl-start { display: inline-flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.tl-start .inp { width: 11rem; }

/* Money by month */
.tl-money { padding: 1.25rem; }
.tl-money-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.tl-money-legend { display: flex; gap: 1.2rem; font-size: .78rem; color: var(--muted); }
.tl-money-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.tl-money-legend b { color: var(--ink); }
.mk { display: inline-block; width: .7rem; height: .7rem; border-radius: .2rem; }
.mk-plan { background: #a5bffb; }
.mk-actual { background: #1d43c0; }
.tl-bars { display: flex; align-items: stretch; gap: 2px; height: 12rem; padding-top: .5rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tl-month { position: relative; flex: 1 0 2.4rem; display: flex; flex-direction: column; justify-content: flex-end; outline: 0; }
.tl-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 3px; }
.tl-b { width: 42%; max-width: 1.1rem; min-height: 0; border-radius: 4px 4px 0 0; }
.tl-b-plan { background: #a5bffb; }
.tl-b-actual { background: #1d43c0; }
.tl-m { position: absolute; bottom: -1.6rem; left: 0; right: 0; text-align: center; font-size: .65rem; color: var(--muted); white-space: nowrap; }
.tl-m small { display: block; font-size: .58rem; color: #94a3b8; }
.tl-month.is-now .tl-m { color: #ef4444; font-weight: 700; }
.tl-month:hover, .tl-month:focus-visible { background: #f8fafc; border-radius: .4rem .4rem 0 0; }
.tl-tip { display: none; position: absolute; bottom: calc(100% + .3rem); left: 50%; transform: translateX(-50%); z-index: 10; min-width: 11rem; padding: .55rem .7rem; border-radius: .6rem;
    background: #fff; border: 1px solid var(--border); box-shadow: 0 12px 28px -12px rgba(15,23,42,.35); font-size: .75rem; color: var(--muted); }
.tl-tip > b { display: block; margin-bottom: .3rem; color: var(--ink); }
.tl-tip span { display: flex; align-items: center; gap: .4rem; }
.tl-tip span b { margin-left: auto; color: var(--ink); }
.tl-month:hover .tl-tip, .tl-month:focus-visible .tl-tip { display: block; }
.tl-money .tl-bars { margin-bottom: 1.8rem; }

/* Stage dialog */
dialog.modal-wide { width: min(44rem, calc(100vw - 2rem)); }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatches label { cursor: pointer; }
.swatches span { display: block; width: 1.6rem; height: 1.6rem; border-radius: .45rem; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 0 3px transparent; transition: box-shadow .15s; }
.swatches input:checked + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c); }
.swatches input:focus-visible + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }
.dur-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.dur-chips button { padding: .1rem .5rem; border-radius: 9999px; font-size: .68rem; font-weight: 600; color: var(--brand); background: #eff4ff; }
.dur-chips button:hover { background: var(--brand); color: #fff; }
.covers { display: flex; flex-wrap: wrap; gap: .35rem; max-height: 12rem; overflow-y: auto; padding: .6rem; border-radius: .6rem; border: 1px solid var(--border); background: #f8fafc; }
.covers-group { width: 100%; margin-top: .2rem; font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; }
.cover { cursor: pointer; }
.cover span { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border-radius: 9999px; font-size: .75rem; font-weight: 500; color: #334155;
    background: #fff; box-shadow: inset 0 0 0 1px var(--border-strong); transition: all .15s; }
.cover small { font-size: .65rem; color: var(--muted); }
.cover input { position: absolute; opacity: 0; pointer-events: none; }
.cover input:checked + span { color: #fff; background: var(--brand); box-shadow: none; }
.cover input:checked + span small { color: #c7d7fe; }
.cover input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }

/* Dark */
html.dark .gantt { --grid: #1c2944; }
html.dark .g-head, html.dark .g-left-head, html.dark .g-legend { background: var(--d-surface-2); border-color: var(--border); }
html.dark .g-left { background: var(--d-surface); border-color: var(--border); }
html.dark .g-row { border-color: var(--border); }
html.dark .g-row:hover .g-left, html.dark .g-row:hover .g-track { background-color: var(--d-surface-3); }
html.dark .g-bar { background: color-mix(in srgb, var(--c) 28%, var(--d-surface)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 75%, var(--d-surface)); }
html.dark .g-bar.is-done { background: var(--c); }
html.dark .g-bar.is-late { box-shadow: inset 0 0 0 2px #f87171; }
html.dark .g-label { color: #e5eaf5; }
html.dark .g-status { background: var(--d-surface-3); color: #94a3b8; }
html.dark .g-status-inprogress { background: rgba(59,110,245,.18); color: #93b4fd; }
html.dark .g-status-done { background: rgba(16,185,129,.15); color: #6ee7b7; }
html.dark .g-status-onhold { background: rgba(245,158,11,.15); color: #fcd34d; }
html.dark .g-status.is-late { background: rgba(239,68,68,.15); color: #fca5a5; }
html.dark .g-links path { stroke: #5f6e89; } html.dark .g-links path.g-arrow { fill: #5f6e89; }
html.dark .tl-kpi-late { border-color: rgba(239,68,68,.4); background: linear-gradient(180deg, var(--d-surface), rgba(239,68,68,.08)); }
html.dark .tl-month:hover, html.dark .tl-month:focus-visible { background: var(--d-surface-3); }
html.dark .tl-tip { background: var(--d-surface); border-color: var(--border-strong); }
html.dark .mk-plan, html.dark .tl-b-plan { background: #4b67b8; }
html.dark .mk-actual, html.dark .tl-b-actual { background: #7da2f7; }
html.dark .covers { background: var(--d-surface-2); border-color: var(--border); }
html.dark .cover span { background: var(--d-surface); color: #cbd5e1; box-shadow: inset 0 0 0 1px var(--border-strong); }
html.dark .cover input:checked + span { background: #3b6ef5; color: #fff; }
html.dark .swatches span { box-shadow: 0 0 0 2px var(--d-surface), 0 0 0 3px transparent; }
html.dark .swatches input:checked + span { box-shadow: 0 0 0 2px var(--d-surface), 0 0 0 4px var(--c); }
html.dark .dur-chips button { background: rgba(59,110,245,.15); color: #93b4fd; }
/* In progress: the label must read on both the filled and the unfilled part. */
.g-bar.is-inprogress .g-fill { opacity: .55; }
.g-bar.is-inprogress .g-label { color: #0f172a; text-shadow: 0 0 3px rgba(255,255,255,.9); }
html.dark .g-bar.is-inprogress .g-label { color: #fff; text-shadow: 0 0 3px rgba(0,0,0,.8); }
/* Money by month: month names inside each column (nothing is clipped, no inner scrollbar). */
.tl-bars { height: auto; padding-top: .5rem; border-bottom: 0; overflow-x: auto; overflow-y: visible; }
.tl-money .tl-bars { margin-bottom: 0; }
.tl-month { height: 13.5rem; }
.tl-pair { border-bottom: 1px solid var(--border); }
.tl-m { position: static; padding-top: .4rem; height: 2rem; }
.tl-tip { bottom: calc(100% - 1rem); }
.tl-bars { overflow: visible; } .tl-month { flex: 1 1 0; min-width: 1.4rem; }

/* ---------- Top bar: tabs ---------- */
header .brand-link { align-self: center; }
header .theme-btn, header .user-menu { align-self: center; }
.top-tabs { display: flex; align-items: stretch; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.top-tabs::-webkit-scrollbar { display: none; }
.top-tab { position: relative; display: inline-flex; align-items: center; gap: .5rem; padding: 0 .9rem; font-size: .875rem; font-weight: 500;
    color: rgba(219,230,254,.72); white-space: nowrap; transition: color .15s, background .15s; }
.top-tab svg { width: 1.1rem; height: 1.1rem; opacity: .8; }
.top-tab::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background .15s; }
.top-tab:hover { color: #fff; background: rgba(255,255,255,.05); }
.top-tab:hover::after { background: rgba(255,255,255,.25); }
.top-tab[aria-current="page"] { color: #fff; font-weight: 600; background: linear-gradient(180deg, transparent, rgba(96,140,255,.16)); }
.top-tab[aria-current="page"] svg { opacity: 1; color: #93b4fd; }
.top-tab[aria-current="page"]::after { background: linear-gradient(90deg, #60a5fa, #a5b4fc); box-shadow: 0 0 12px rgba(96,165,250,.7); }
.top-tab:focus-visible { outline: none; box-shadow: inset 0 0 0 2px rgba(147,180,253,.7); border-radius: .4rem; }
@media (max-width: 900px) { .top-tab span { display: none; } .top-tab { padding: 0 .75rem; } }

/* ---------- Contractor cards (read-only, edit in a dialog) ---------- */
.ccard-title { font-weight: 650; font-size: 1rem; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard-trade { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .05rem; }
.ccard-edit { display: inline-flex; align-items: center; gap: .35rem; flex-shrink: 0; height: 2rem; padding: 0 .7rem; border-radius: .5rem; font-size: .78rem; font-weight: 600;
    color: var(--brand); background: #eff4ff; box-shadow: inset 0 0 0 1px #d6e2fe; transition: background .15s, color .15s, box-shadow .15s; }
.ccard-edit svg { width: .95rem; height: .95rem; }
.ccard-edit:hover { background: var(--brand); color: #fff; box-shadow: 0 6px 14px -6px rgba(59,110,245,.6); }
.ccard-edit:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.ccard-phone { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .9rem; padding: .45rem .55rem .45rem .75rem;
    border: 1px solid var(--border); border-radius: .55rem; font-size: .85rem; font-weight: 500; color: var(--ink); min-height: 2.4rem; }
.ccard-note { margin-top: .85rem; padding: .7rem .85rem .75rem; border-radius: .6rem; background: #fffbeb; box-shadow: inset 0 0 0 1px #fde68a; border-left: 3px solid #f59e0b; }
.ccard-note-head { display: flex; align-items: center; gap: .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #b45309; }
.ccard-note-head svg { width: .9rem; height: .9rem; }
.ccard-note p { margin-top: .3rem; font-size: .85rem; line-height: 1.45; color: #1e293b; white-space: pre-line; overflow-wrap: anywhere; }
html.dark .ccard-title { color: var(--ink); }
html.dark .ccard-edit { background: rgba(96,140,255,.12); color: #a5c0ff; box-shadow: inset 0 0 0 1px rgba(96,140,255,.3); }
html.dark .ccard-edit:hover { background: #3b6ef5; color: #fff; }
html.dark .ccard-phone { border-color: var(--border); }
html.dark .ccard-note { background: rgba(245,158,11,.08); box-shadow: inset 0 0 0 1px rgba(245,158,11,.25); border-left-color: #f59e0b; }
html.dark .ccard-note-head { color: #fbbf24; }
html.dark .ccard-note p { color: #e2e8f0; }
[data-contractor-dialog] [data-f="delete"] { color: #be123c; }
html.dark [data-contractor-dialog] [data-f="delete"] { color: #fda4af; }

/* ---------- Contract card field labels ---------- */
.cc-lbls { font-size: .68rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); line-height: 1.2; }
.cc-lbls > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-lbls i { font-style: normal; font-weight: 400; color: #94a3b8; }
.ct-rows .cc-lbls { display: none; }
.ct-small .cc-lbls { margin-top: .5rem !important; font-size: .62rem; }
.ct-small .cc-lbls i { display: none; }
.ct-small .cc-price { margin-top: .2rem !important; }
.ct-small .cc-rate { margin-top: .2rem !important; }
html.dark .cc-lbls i { color: #64748b; }

/* ---------- Materials: "Supplied by" picker ---------- */
.supply-pick { position: relative; display: flex; align-items: center; gap: .45rem; height: 2.1rem; padding: 0 .45rem 0 .3rem; min-width: 11rem;
    border: 1px solid var(--border-strong); border-radius: .55rem; background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.supply-pick:hover { border-color: #94a3b8; }
.supply-pick:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.supply-pick input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: .8125rem; font-weight: 500; color: var(--ink); cursor: pointer; text-overflow: ellipsis; }
.supply-pick input:focus { cursor: text; }
.supply-chev { width: 1rem; height: 1rem; flex-shrink: 0; color: #94a3b8; pointer-events: none; }
.supply-av, .supply-ico { display: grid; place-items: center; flex-shrink: 0; width: 1.5rem; height: 1.5rem; border-radius: 9999px; font-size: .6rem; font-weight: 700; color: #fff; }
.supply-ico svg { width: .9rem; height: .9rem; }
.supply-pick.is-me .supply-ico { background: #f1f5f9; color: #64748b; }
.supply-pick.is-me input { color: var(--muted); }
.supply-pick.is-shop { background: #f5f8ff; border-color: #c7d7fe; }
.supply-pick.is-contract { background: #f5f3ff; border-color: #ddd6fe; }
.supply-pick.is-contract .supply-ico { border-radius: .4rem; background: #ede9fe; color: #6d28d9; }
.picker-item-ico.is-me { background: #f1f5f9; color: #64748b; }
html.dark .supply-pick { background: var(--d-input); border-color: var(--border-strong); }
html.dark .supply-pick.is-shop { background: rgba(96,140,255,.1); border-color: rgba(96,140,255,.35); }
html.dark .supply-pick.is-contract { background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.35); }
html.dark .supply-pick.is-contract .supply-ico { background: rgba(139,92,246,.25); color: #c4b5fd; }
html.dark .supply-pick.is-me .supply-ico, html.dark .picker-item-ico.is-me { background: rgba(148,163,184,.15); color: #94a3b8; }
/* the field draws its own chevron */
.supply-pick input[data-picker], .supply-pick input[data-picker][aria-expanded="true"] { background-image: none; padding-right: 0; }
.supply-pick:has(input[aria-expanded="true"]) .supply-chev { transform: rotate(180deg); color: var(--brand); }
.supply-chev { transition: transform .15s; }

/* ---------- Notes: icon + pop-up ---------- */
.note-btn { position: relative; display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: .5rem; color: #94a3b8;
    border: 1px dashed #cbd5e1; background: transparent; transition: color .15s, background .15s, border-color .15s, box-shadow .15s; }
.note-btn svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; }
.note-btn:hover { color: var(--brand); border-color: var(--brand); border-style: solid; background: #eff4ff; }
.note-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.note-btn.has-note { color: #b45309; border: 1px solid #fcd34d; background: #fffbeb; }
.note-btn.has-note::after { content: ""; position: absolute; top: -3px; right: -3px; width: .5rem; height: .5rem; border-radius: 9999px; background: #f59e0b; box-shadow: 0 0 0 2px #fff; }
.note-btn.has-note:hover { background: #fef3c7; border-color: #f59e0b; }
/* wide: icon + the start of the note */
.note-btn-wide { display: inline-flex; width: auto; max-width: 100%; gap: .4rem; padding: 0 .6rem 0 .5rem; height: 1.85rem; font-size: .75rem; font-weight: 500; }
.note-btn-wide span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-btn-wide.has-note span { color: #78350f; }
.note-btn-wide.has-note::after { display: none; }
/* contract cards: a footer line */
.ccard > .cc-notes { margin-top: .75rem; padding-top: .6rem; border-top: 1px dashed var(--border); min-width: 0; }
.ct-rows .cc-notes { min-width: 0; }
.ct-rows .cc-notes .note-btn-wide { height: 1.5rem; font-size: .68rem; border-color: transparent; }
.ct-rows .ccard:hover .cc-notes .note-btn-wide:not(.has-note) { border-color: #cbd5e1; }
/* library: next to the badges under the name */
.lib-sub .note-btn-wide { height: 1.45rem; font-size: .68rem; border-color: transparent; padding: 0 .45rem; }
.lib-row:hover .lib-sub .note-btn-wide:not(.has-note) { border-color: #cbd5e1; }
/* the pop-up */
dialog.note-modal { width: min(30rem, calc(100vw - 2rem)); }
.note-modal-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: .7rem; background: #fef3c7; color: #b45309; }
.note-modal-ico svg { width: 1.25rem; height: 1.25rem; }
.note-area { width: 100%; resize: vertical; min-height: 7rem; line-height: 1.5; text-align: left; }
.note-area[readonly] { background: #f8fafc; }
.note-count { margin-top: .35rem; text-align: right; font-size: .68rem; color: #94a3b8; }
.note-clear { color: #be123c; }
html.dark .note-btn { border-color: #334155; color: #64748b; }
html.dark .note-btn:hover { background: rgba(96,140,255,.12); color: #a5c0ff; border-color: #3b6ef5; }
html.dark .note-btn.has-note { color: #fbbf24; background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.4); }
html.dark .note-btn.has-note::after { box-shadow: 0 0 0 2px var(--d-surface); }
html.dark .note-btn-wide.has-note span { color: #fde68a; }
html.dark .note-modal-ico { background: rgba(245,158,11,.15); color: #fbbf24; }
html.dark .note-area[readonly] { background: var(--d-surface-2); }
html.dark .note-clear { color: #fda4af; }

/* ---------- Materials: category band with its totals ---------- */
.tbl tr.cat-row td { padding: 0; background: none; border-top: 0; }
.tbl tr.cat-row:not(:first-child) td { padding-top: .9rem; }
.cat-band { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1.5rem; padding: .7rem 1rem .7rem .9rem;
    border-left: 4px solid var(--cat); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, color-mix(in srgb, var(--cat) 12%, #fff), color-mix(in srgb, var(--cat) 3%, #fff) 60%); }
.cat-band .cat-head { font-size: .9rem; font-weight: 700; color: var(--ink); }
.cat-band .cat-count { padding: .05rem .5rem; border-radius: 9999px; background: color-mix(in srgb, var(--cat) 14%, #fff); color: color-mix(in srgb, var(--cat) 70%, #0f172a); font-weight: 600; }
.cat-sum { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.cat-stat { display: flex; flex-direction: column; line-height: 1.15; }
.cat-stat span { font-size: .62rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cat-stat b { font-size: .9rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-stat.is-over b { color: #dc2626; }
.cat-progress { display: flex; align-items: center; gap: .5rem; }
.cat-bar { width: 7rem; height: .4rem; border-radius: 9999px; background: color-mix(in srgb, var(--cat) 15%, #e2e8f0); overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: inherit; background: var(--cat); }
.cat-bar.is-over i { background: #ef4444; }
.cat-progress small { font-size: .7rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.2rem; }
html.dark .cat-band { border-color: var(--border); background: linear-gradient(90deg, color-mix(in srgb, var(--cat) 18%, var(--d-surface)), color-mix(in srgb, var(--cat) 4%, var(--d-surface)) 60%); }
html.dark .cat-band .cat-count { background: color-mix(in srgb, var(--cat) 22%, var(--d-surface)); color: color-mix(in srgb, var(--cat) 55%, #fff); }
html.dark .cat-bar { background: color-mix(in srgb, var(--cat) 18%, #1e293b); }
html.dark .cat-stat.is-over b { color: #f87171; }
html.dark .tbl tr.cat-row td { background: none; }

/* ---------- Project hero: dates & progress strip ---------- */
.proj-sched { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto); align-items: center; gap: 1rem 2rem;
    padding: .9rem 1.1rem; border-radius: .9rem; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); color: #fff; }
.ps-dates { display: flex; align-items: center; gap: .85rem; flex-wrap: wrap; }
.ps-ico { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .7rem; background: rgba(255,255,255,.12); color: #c7d7fe; flex-shrink: 0; }
.ps-ico svg { width: 1.25rem; height: 1.25rem; }
.ps-date { display: flex; flex-direction: column; line-height: 1.2; }
.ps-date span { font-size: .65rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(199,215,254,.8); }
.ps-date b { font-size: .95rem; font-weight: 700; white-space: nowrap; }
.ps-date b.is-empty { color: rgba(255,255,255,.45); font-weight: 500; }
.ps-arrow { width: 1.1rem; height: 1.1rem; color: rgba(199,215,254,.6); }
.ps-edit { display: inline-flex; align-items: center; gap: .35rem; height: 2rem; padding: 0 .75rem; border-radius: .55rem; font-size: .78rem; font-weight: 600;
    color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); transition: background .15s; }
.ps-edit svg { width: .95rem; height: .95rem; }
.ps-edit:hover { background: rgba(255,255,255,.22); }
.ps-bars { display: grid; gap: .45rem; min-width: 0; }
.ps-bar-row { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr) 2.6rem; align-items: center; gap: .6rem; }
.ps-bar-label { font-size: .72rem; font-weight: 600; color: rgba(199,215,254,.85); white-space: nowrap; }
.ps-bar-val { font-size: .78rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ps-bar { height: .5rem; border-radius: 9999px; background: rgba(255,255,255,.12); overflow: hidden; }
.ps-bar i { display: block; height: 100%; border-radius: inherit; }
.ps-bar-time i { background: repeating-linear-gradient(135deg, #93b4fd 0 6px, #7c9ef8 6px 12px); }
.ps-bar-work i { background: linear-gradient(90deg, #34d399, #10b981); }
.ps-bar-work.is-bad i { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.ps-state { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; text-align: right; }
.ps-state small { font-size: .72rem; color: rgba(219,230,254,.8); }
.ps-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .7rem; border-radius: 9999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.ps-pill i { width: .45rem; height: .45rem; border-radius: 9999px; background: currentColor; }
.ps-pill.is-ok { background: rgba(16,185,129,.18); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(16,185,129,.4); }
.ps-pill.is-behind { background: rgba(245,158,11,.18); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245,158,11,.45); }
.ps-pill.is-late { background: rgba(239,68,68,.2); color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(239,68,68,.5); }
.ps-pill.is-wait { background: rgba(147,180,253,.16); color: #c7d7fe; box-shadow: inset 0 0 0 1px rgba(147,180,253,.4); }
.ps-pill.is-done { background: rgba(16,185,129,.25); color: #a7f3d0; box-shadow: inset 0 0 0 1px rgba(16,185,129,.55); }
.ps-pill.is-none { background: rgba(255,255,255,.1); color: rgba(255,255,255,.75); box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
.ps-state .ps-slip-bad { color: #fcd34d; }
.ps-state .ps-slip-ok { color: #6ee7b7; }
@media (max-width: 1023px) {
    .proj-sched { grid-template-columns: minmax(0, 1fr); }
    .ps-state { align-items: flex-start; text-align: left; }
}
/* dates dialog */
.dates-quick { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .9rem; font-size: .75rem; color: var(--muted); }
.dates-quick span { margin-right: .2rem; }
/* timeline: the project's target finish */
.g-target { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed #7c3aed; opacity: .75; z-index: 2; pointer-events: none; }
.g-target-label { position: absolute; bottom: 2px; transform: translateX(-50%); padding: 0 .35rem; border-radius: .3rem; font-size: .6rem; font-weight: 700; color: #fff; background: #7c3aed; z-index: 2; white-space: nowrap; }
.lg-target { width: 0; height: .9rem; border-left: 2px dashed #7c3aed; border-radius: 0; background: none; }
html.dark .g-target { border-color: #a78bfa; }
html.dark .g-target-label { background: #6d28d9; }
/* timeline: days outside the project's start … target finish (stages can't go there) */
.g-out { position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none;
    background: repeating-linear-gradient(135deg, rgba(148,163,184,.12) 0 6px, transparent 6px 12px); }
html.dark .g-out { background: repeating-linear-gradient(135deg, rgba(148,163,184,.08) 0 6px, transparent 6px 12px); }

/* ---------- Library: category bands + "Add to library" dialog ---------- */
.cat-add { display: inline-flex; align-items: center; gap: .3rem; height: 1.9rem; padding: 0 .75rem; border-radius: .5rem; font-size: .75rem; font-weight: 600; white-space: nowrap;
    color: color-mix(in srgb, var(--cat) 75%, #0f172a); background: #fff; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 35%, #e2e8f0); transition: background .15s, color .15s, box-shadow .15s; }
.cat-add svg { width: .85rem; height: .85rem; }
.cat-add:hover { background: var(--cat); color: #fff; box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--cat) 70%, transparent); }
html.dark .cat-add { background: var(--d-surface); color: color-mix(in srgb, var(--cat) 55%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 40%, var(--border)); }
html.dark .cat-add:hover { background: var(--cat); color: #fff; }

dialog[data-lib-dialog] { width: min(40rem, calc(100vw - 2rem)); }
.lib-sec { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.lib-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.lib-sec-note { font-size: .7rem; font-weight: 600; color: var(--muted); }

.lib-kinds { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.lib-kind { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: .75rem; cursor: pointer;
    border: 1px solid var(--border-strong); background: #fff; transition: border-color .15s, box-shadow .15s, background .15s; }
.lib-kind:hover { border-color: #94a3b8; }
.lib-kind b { display: block; font-size: .875rem; font-weight: 650; color: var(--ink); }
.lib-kind small { display: block; font-size: .72rem; color: var(--muted); }
.lib-kind-ico { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: .6rem; background: #f1f5f9; color: #64748b; }
.lib-kind-ico svg { width: 1.15rem; height: 1.15rem; }
.lib-kind:has(input:checked) { border-color: var(--brand); background: #f5f8ff; box-shadow: 0 0 0 3px var(--brand-ring); }
.lib-kind:has(input:checked) .lib-kind-ico { background: var(--brand); color: #fff; }
.lib-kind:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

.lib-cat-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.lib-cat-chip { display: inline-flex; align-items: center; gap: .4rem; height: 1.9rem; padding: 0 .7rem 0 .55rem; border-radius: 9999px; font-size: .78rem; font-weight: 500;
    color: #334155; background: #fff; box-shadow: inset 0 0 0 1px var(--border-strong); transition: background .15s, color .15s, box-shadow .15s; }
.lib-cat-chip i { width: .55rem; height: .55rem; border-radius: 9999px; background: var(--cat); }
.lib-cat-chip:hover { box-shadow: inset 0 0 0 1px var(--cat); background: color-mix(in srgb, var(--cat) 6%, #fff); }
.lib-cat-chip[aria-checked="true"] { color: #fff; background: var(--cat); box-shadow: 0 6px 14px -8px var(--cat); font-weight: 600; }
.lib-cat-chip[aria-checked="true"] i { background: #fff; }
.lib-cat-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.lib-basis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.lib-basis-opt { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .7rem; border-radius: .65rem; cursor: pointer;
    border: 1px solid var(--border-strong); background: #fff; transition: border-color .15s, box-shadow .15s, background .15s; }
.lib-basis-opt svg { width: 1.1rem; height: 1.1rem; color: #94a3b8; margin-bottom: .2rem; }
.lib-basis-opt b { font-size: .8125rem; font-weight: 650; color: var(--ink); }
.lib-basis-opt small { font-size: .68rem; color: var(--muted); line-height: 1.3; }
.lib-basis-opt:hover { border-color: #94a3b8; }
.lib-basis-opt:has(input:checked) { border-color: var(--brand); background: #f5f8ff; box-shadow: 0 0 0 3px var(--brand-ring); }
.lib-basis-opt:has(input:checked) svg { color: var(--brand); }
.lib-basis-opt:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 520px) { .lib-kinds, .lib-basis { grid-template-columns: 1fr; } }

html.dark .lib-kind, html.dark .lib-basis-opt, html.dark .lib-cat-chip { background: var(--d-input); border-color: var(--border-strong); color: var(--ink); }
html.dark .lib-cat-chip { box-shadow: inset 0 0 0 1px var(--border-strong); color: #cbd5e1; }
html.dark .lib-cat-chip[aria-checked="true"] { background: var(--cat); color: #fff; }
html.dark .lib-kind:has(input:checked), html.dark .lib-basis-opt:has(input:checked) { background: rgba(59,110,245,.12); border-color: #3b6ef5; }
html.dark .lib-kind-ico { background: rgba(148,163,184,.15); color: #94a3b8; }
/* delete that isn't allowed (e.g. a line with spending): shown greyed with the reason on hover */
.floor-del.is-locked { opacity: .35; cursor: not-allowed; display: inline-grid; place-items: center; }
.floor-del.is-locked:hover, .floor-del.is-locked:focus-visible { opacity: .6; background: transparent; color: #94a3b8; }

/* ---------- Confirmation dialog ---------- */
.btn-danger { background: #dc2626; color: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.15); }
.btn-danger:hover { background: #b91c1c; }
.btn-danger:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220,38,38,.35); }
dialog.confirm-modal { width: min(27rem, calc(100vw - 2rem)); }
.confirm-body { display: flex; gap: 1rem; padding: 1.5rem 1.5rem 1.25rem; }
.confirm-ico { display: grid; place-items: center; flex-shrink: 0; width: 2.75rem; height: 2.75rem; border-radius: 9999px; }
.confirm-ico svg { width: 1.35rem; height: 1.35rem; }
.confirm-modal[data-tone="danger"] .confirm-ico { background: #fee2e2; color: #dc2626; box-shadow: 0 0 0 6px #fef2f2; }
.confirm-modal[data-tone="primary"] .confirm-ico { background: #dbeafe; color: var(--brand); box-shadow: 0 0 0 6px #eff6ff; }
.confirm-title { font-size: 1.02rem; font-weight: 700; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; margin-top: .15rem; }
.confirm-text { margin-top: .4rem; font-size: .85rem; line-height: 1.5; color: var(--muted); }
.confirm-foot { display: flex; justify-content: flex-end; gap: .6rem; padding: .9rem 1.5rem; background: #f8fafc; border-top: 1px solid var(--border); border-radius: 0 0 1rem 1rem; }
@media (max-width: 480px) { .confirm-foot { flex-direction: column-reverse; } .confirm-foot .btn { justify-content: center; } }
html.dark .confirm-foot { background: var(--d-surface-2); border-color: var(--border); }
html.dark .confirm-modal[data-tone="danger"] .confirm-ico { background: rgba(220,38,38,.18); color: #f87171; box-shadow: 0 0 0 6px rgba(220,38,38,.08); }
html.dark .confirm-modal[data-tone="primary"] .confirm-ico { background: rgba(59,110,245,.2); color: #93b4fd; box-shadow: 0 0 0 6px rgba(59,110,245,.08); }

/* ---------- Contractor categories (trades) ---------- */
.trade-badge { display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; margin-top: .2rem; padding: .1rem .55rem .1rem .45rem; border-radius: 9999px;
    font-size: .72rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: color-mix(in srgb, var(--cat) 72%, #0f172a); background: color-mix(in srgb, var(--cat) 12%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 25%, transparent); }
.trade-badge i { width: .45rem; height: .45rem; border-radius: 9999px; background: var(--cat); flex-shrink: 0; }
.trade-badge.is-none { color: #94a3b8; background: #f8fafc; box-shadow: inset 0 0 0 1px #e2e8f0; font-weight: 500; }
html.dark .trade-badge { color: color-mix(in srgb, var(--cat) 55%, #fff); background: color-mix(in srgb, var(--cat) 18%, var(--d-surface)); }
html.dark .trade-badge.is-none { color: #64748b; background: var(--d-surface-2); box-shadow: inset 0 0 0 1px var(--border); }

dialog[data-trades-dialog] { width: min(34rem, calc(100vw - 2rem)); }
.tm-add { display: flex; align-items: center; gap: .5rem; padding: .35rem .35rem .35rem .75rem; border-radius: .65rem; border: 1px dashed #93b4fd; background: #f5f8ff; }
.tm-add-ico { display: grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: .45rem; background: var(--brand); color: #fff; flex-shrink: 0; }
.tm-add-ico svg { width: .9rem; height: .9rem; }
.tm-add input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: .875rem; color: var(--ink); }
.tm-list { margin-top: .9rem; max-height: min(55vh, 26rem); overflow-y: auto; border: 1px solid var(--border); border-radius: .75rem; }
.tm-row { display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem .35rem .8rem; border-bottom: 1px solid #eef2f7; }
.tm-row:last-child { border-bottom: 0; }
.tm-row:hover { background: #fafcff; }
.tm-dot { width: .6rem; height: .6rem; border-radius: 9999px; background: var(--cat); flex-shrink: 0; }
.tm-name { flex: 1; min-width: 0; padding: .35rem .5rem; border: 1px solid transparent; border-radius: .45rem; background: transparent; font-size: .875rem; font-weight: 600; color: var(--ink); }
.tm-name:hover { border-color: var(--border); }
.tm-name:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: #fff; }
.tm-count { font-size: .72rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tm-count.is-zero { color: #cbd5e1; font-weight: 500; }
.tm-empty { margin-top: 1rem; text-align: center; font-size: .85rem; color: var(--muted); }
html.dark .tm-add { background: rgba(59,110,245,.08); border-color: rgba(96,140,255,.45); }
html.dark .tm-list { border-color: var(--border); }
html.dark .tm-row { border-color: var(--border); }
html.dark .tm-row:hover { background: rgba(255,255,255,.02); }
html.dark .tm-name:focus { background: var(--d-input); }
html.dark .tm-count.is-zero { color: #475569; }
/* contractor cards: several categories */
.trade-badges { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.trade-badges .trade-badge { margin-top: 0; }
.trade-new { display: flex; gap: .5rem; }
.trade-new .inp { flex: 1; min-width: 0; }
/* contractor categories come from the library's contracts */
.trade-src { display: flex; align-items: flex-start; gap: .4rem; margin-top: .6rem; font-size: .72rem; color: var(--muted); }
.trade-src svg { width: .95rem; height: .95rem; flex-shrink: 0; margin-top: .05rem; }
.trade-src a { color: var(--brand); font-weight: 600; white-space: nowrap; }
.trade-src a:hover { text-decoration: underline; }
.lib-cat-chip.is-old { font-style: italic; }
.trade-badge.is-old { font-style: italic; opacity: .8; }
html.dark .trade-src a { color: #93b4fd; }

/* ---------- Contract cards: drag to rearrange ---------- */
.cc-grip { display: grid; place-items: center; flex-shrink: 0; width: 1.4rem; height: 2.25rem; margin: 0 -.35rem 0 -.5rem; border-radius: .4rem;
    color: #a3b1c4; cursor: grab; touch-action: none; transition: color .15s, background .15s; }
.cc-grip svg { width: 1rem; height: 1rem; }
.ccard:hover .cc-grip { color: #64748b; }
.cc-grip:hover { color: var(--brand) !important; background: #eff4ff; }
.cc-grip:active { cursor: grabbing; }
.cc-grip:focus-visible { outline: none; color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.cc-ghost { opacity: .35; border-style: dashed !important; border-color: var(--brand) !important; box-shadow: none !important; }
.cc-ghost > * { visibility: hidden; }
.cc-chosen { box-shadow: 0 18px 40px -16px rgba(27,47,110,.45) !important; }
.cc-dragging { transform: rotate(1.5deg); }
.ct-small .cc-grip, .ct-rows .cc-grip { height: 1.75rem; }
.ct-rows .cc-grip { opacity: 0; }
.ct-rows .ccard:hover .cc-grip, .ct-rows .cc-grip:focus-visible { opacity: 1; }
html.dark .cc-grip { color: #475569; }
html.dark .ccard:hover .cc-grip { color: #64748b; }
html.dark .cc-grip:hover { background: rgba(96,140,255,.12); color: #93b4fd !important; }

/* ---------- Contract cards: numbered, coloured by category ---------- */
.ccard.cc-cat { position: relative; border-top: 3px solid var(--cat); }
.cc-num { display: grid; place-items: center; flex-shrink: 0; min-width: 2.25rem; height: 2.25rem; padding: 0 .4rem; border-radius: .6rem;
    font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fff; background: var(--cat);
    box-shadow: 0 6px 14px -8px var(--cat), inset 0 -2px 0 rgba(0,0,0,.12); }
.ct-small .cc-num { min-width: 1.75rem; height: 1.75rem; font-size: .8rem; border-radius: .5rem; }
.ct-rows .ccard.cc-cat { border-top: 0; }
.ct-rows .cc-num { min-width: 1.6rem; height: 1.6rem; font-size: .75rem; border-radius: .45rem; }

/* ---------- Materials: pricing & quantity per row ---------- */
.mat-table .qty-cell { min-width: 13.5rem; }
.qty-cell .per-sqft { width: 100%; }
.qty-basis { width: 100%; text-align: left; text-align-last: left; margin-bottom: .35rem; font-size: .72rem !important; padding-top: .2rem !important; padding-bottom: .2rem !important; color: var(--muted); background-color: #f8fafc; }
.qty-fixed { display: flex; gap: .35rem; }
.qty-fixed .inp:first-child { flex: 1; min-width: 0; text-align: right; }
.qty-fixed .qty-unit { width: 4.5rem; flex-shrink: 0; text-align: left; }
.qty-lump { display: block; font-size: .7rem; color: #94a3b8; line-height: 1.3; padding: .2rem .1rem; }
html.dark .qty-basis { background-color: var(--d-surface-2); }

/* ---------- Purchase orders ---------- */
.po-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); }
.po-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: .9rem; border-left: 4px solid #94a3b8;
    box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: box-shadow .2s, border-color .2s; }
.po-card:hover { box-shadow: 0 14px 30px -20px rgba(27,47,110,.4); }
.po-card.is-sent { border-left-color: #f59e0b; }
.po-card.is-priced { border-left-color: var(--brand); }
.po-card.is-logged { border-left-color: #10b981; }
.po-card.is-cancelled { border-left-color: #cbd5e1; opacity: .7; }
.po-card[data-just-saved] { box-shadow: 0 0 0 3px var(--brand-ring); }
.po-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1rem 1.1rem .75rem; }
.po-code { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.po-status { display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .55rem; border-radius: 9999px; font-size: .7rem; font-weight: 700; }
.po-status i { width: .45rem; height: .45rem; border-radius: 9999px; background: currentColor; }
.po-status.is-draft { color: #475569; background: #f1f5f9; }
.po-status.is-sent { color: #b45309; background: #fef3c7; }
.po-status.is-priced { color: #1d43c0; background: #e0e9ff; }
.po-status.is-logged { color: #047857; background: #d1fae5; }
.po-status.is-cancelled { color: #64748b; background: #f1f5f9; text-decoration: line-through; }
.po-to { margin-top: .3rem; font-size: .8rem; color: var(--muted); }
.po-to b { color: var(--ink); font-weight: 600; }
.po-dot { margin: 0 .35rem; color: #cbd5e1; }
.po-money { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; text-align: right; flex-shrink: 0; }
.po-money span { display: block; font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.po-money b { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.po-money small { display: block; font-size: .68rem; color: #b45309; }
.po-money .po-est b { font-size: .85rem; font-weight: 600; color: var(--muted); }
.po-lines { margin: 0 1.1rem; padding: .3rem 0; border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); max-height: 13rem; overflow-y: auto; }
.po-lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto 6rem; gap: .75rem; align-items: baseline; padding: .3rem 0; font-size: .82rem; }
.po-line-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.po-line-name small { margin-left: .35rem; color: #94a3b8; font-weight: 400; }
.po-line-qty { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.po-line-qty small { font-weight: 500; color: var(--muted); }
.po-line-rate { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.po-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .75rem 1.1rem .9rem; }
.po-actions .floor-del { width: 2rem; height: 2rem; }

dialog.po-dialog { width: min(56rem, calc(100vw - 2rem)); }
.po-edit-head { display: flex; align-items: center; justify-content: space-between; margin: 1.1rem 0 .4rem; }
.po-edit { width: 100%; border-collapse: separate; border-spacing: 0 .35rem; }
.po-edit th { padding: 0 .3rem; font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); text-align: left; }
.po-edit th.text-right { text-align: right; }
.po-edit td { padding: 0 .3rem; vertical-align: middle; }
.po-edit td:first-child { width: 34%; }
.po-edit td:nth-child(2) { width: 13%; }
.po-edit td:nth-child(3) { width: 10%; }
.po-edit td:last-child { width: 2.5rem; }
.po-edit .floor-del { width: 2rem; height: 2rem; }
.po-edit-est { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.po-add-line { display: flex; align-items: center; justify-content: center; gap: .4rem; width: 100%; margin-top: .35rem; padding: .55rem; border: 1px dashed #93b4fd; border-radius: .6rem;
    font-size: .8rem; font-weight: 600; color: var(--brand); background: #f5f8ff; transition: background .15s; }
.po-add-line:hover { background: #eaf0ff; }
.po-add-line svg { width: .9rem; height: .9rem; }
.po-prices td { padding-top: .25rem; padding-bottom: .25rem; }
.po-prices td:first-child { width: 40%; }
.po-prices small { font-size: .7rem; }
.po-rate { max-width: 10rem; margin-left: auto; }
.po-rate .inp { text-align: right; }
.po-log { display: grid; grid-template-columns: 12rem minmax(0, 1fr); align-items: end; gap: 1rem; margin-top: 1rem; padding: .8rem 1rem; border-radius: .7rem; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; }
@media (max-width: 640px) { .po-log { grid-template-columns: 1fr; } .po-edit td:nth-child(4), .po-edit th:nth-child(4), .po-edit td:nth-child(5), .po-edit th:nth-child(5) { display: none; } }

html.dark .po-card { background: var(--d-surface); border-color: var(--border); }
html.dark .po-status.is-draft, html.dark .po-status.is-cancelled { color: #cbd5e1; background: rgba(148,163,184,.15); }
html.dark .po-status.is-sent { color: #fcd34d; background: rgba(245,158,11,.15); }
html.dark .po-status.is-priced { color: #a5c0ff; background: rgba(59,110,245,.18); }
html.dark .po-status.is-logged { color: #6ee7b7; background: rgba(16,185,129,.15); }
html.dark .po-add-line { background: rgba(59,110,245,.08); border-color: rgba(96,140,255,.45); color: #a5c0ff; }
html.dark .po-log { background: rgba(16,185,129,.08); box-shadow: inset 0 0 0 1px rgba(16,185,129,.3); }
.po-edit .inp { text-align: left; }
.po-edit [data-l="qty"] { text-align: right; }
.po-prices td:nth-child(3) { width: 11rem; }
.po-prices .po-rate { width: 10rem; max-width: none; }
.po-prices .po-rate .inp { min-width: 0; width: 100%; }
.po-edit [data-l="name"].is-unknown { border-color: #f59e0b; background: #fffbeb; }
.po-filter { margin: -.1rem 0 .3rem; padding: .4rem .7rem; border-radius: .5rem; font-size: .75rem; color: #1c389b; background: #eff4ff; }
html.dark .po-filter { color: #a5c0ff; background: rgba(59,110,245,.12); }

/* ---------- Order dialog: big enough for 20+ lines ---------- */
dialog[data-order-dialog] { width: min(76rem, calc(100vw - 2rem)); height: calc(100vh - 2.5rem); max-height: none; }
dialog[data-order-dialog] > form { display: flex; flex-direction: column; height: 100%; }
dialog[data-order-dialog] .modal-body { flex: 1; min-height: 0; max-height: none; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 1rem; }
.po-lines-box { flex: 1; min-height: 9rem; overflow-y: auto; border: 1px solid var(--border); border-radius: .7rem; padding: 0 .5rem .5rem; }
.po-lines-box .po-edit { border-spacing: 0 .25rem; }
.po-lines-box .po-edit thead th { position: sticky; top: 0; z-index: 1; padding-top: .55rem; padding-bottom: .35rem; background: #fff; }
.po-lines-box .po-add-line { position: sticky; bottom: 0; background: #f5f8ff; }
.po-count { margin-left: .25rem; font-weight: 500; color: var(--muted); }
dialog[data-order-dialog] .modal-body > label.mt-4 { margin-top: .75rem; }
dialog[data-order-dialog] textarea[name="notes"] { min-height: 2.5rem; }
dialog[data-order-dialog] .modal-est { margin-top: .75rem; padding: .6rem 1rem; }
html.dark .po-lines-box { border-color: var(--border); }
html.dark .po-lines-box .po-edit thead th { background: var(--d-surface); }
@media (max-height: 640px) { dialog[data-order-dialog] { height: calc(100vh - 1rem); } }

/* ---------- Contractor payments ---------- */
.pv-sub { margin: 0 0 .6rem; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pv-contract { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; color: var(--ink); }
.pv-contract i { width: .55rem; height: .55rem; border-radius: 9999px; background: var(--cat); flex-shrink: 0; }
.pv-table td { vertical-align: middle; }
.pv-paid { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; font-variant-numeric: tabular-nums; }
.pv-paid span { color: var(--muted); font-size: .72rem; }
.pv-bar { position: relative; display: flex; height: .35rem; margin-top: .3rem; border-radius: 9999px; background: #eef2f7; overflow: hidden; min-width: 7rem; }
.pv-bar i { display: block; height: 100%; background: var(--cat, var(--brand)); }
.pv-bar b { display: block; height: 100%; background: repeating-linear-gradient(135deg, #f59e0b 0 5px, #fbbf24 5px 10px); }
.pv-bar-lg { height: .55rem; margin-top: .8rem; }

.pv-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); }
.pv-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--cat); border-radius: .9rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.pv-card.is-cancelled { opacity: .65; }
.pv-card[data-just-saved] { box-shadow: 0 0 0 3px var(--brand-ring); }
.pv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1rem 1.1rem .4rem; }
.pv-to { margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.pv-to b { color: var(--ink); font-weight: 600; }
.pv-amount { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pv-card.is-cancelled .pv-amount { text-decoration: line-through; color: var(--muted); }
.pv-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; padding: 0 1.1rem .6rem; font-size: .76rem; color: var(--muted); }
.pv-meta .pv-purpose { color: var(--ink); font-weight: 500; }
.pv-done { font-size: .75rem; font-weight: 600; color: #047857; }

dialog.pv-dialog { width: min(56rem, calc(100vw - 2rem)); }
.pv-form { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: 1.5rem; }
.pv-fields { display: grid; gap: 1rem; align-content: start; }
.pv-amt .inp { font-size: 1.05rem; font-weight: 700; }
.pv-modes { display: flex; flex-wrap: wrap; gap: .35rem; }
.pv-modes span { display: inline-block; padding: .4rem .75rem; border-radius: .5rem; font-size: .8rem; font-weight: 500; color: #334155; cursor: pointer;
    box-shadow: inset 0 0 0 1px var(--border-strong); transition: background .15s, color .15s, box-shadow .15s; }
.pv-modes input:checked + span { color: #fff; background: var(--brand); box-shadow: none; }
.pv-modes input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }
.pv-summary { padding: 1rem 1.1rem; border-radius: .8rem; background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); align-self: start; }
.label-sm { display: block; font-size: .65rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.pv-who { margin: .2rem 0 .6rem; font-weight: 600; font-size: .9rem; }
.pv-summary dl { margin: 0; }
.pv-summary dl div { display: flex; justify-content: space-between; gap: .75rem; padding: .3rem 0; font-size: .82rem; border-bottom: 1px dashed var(--border); }
.pv-summary dt { color: var(--muted); }
.pv-summary dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.pv-summary .pv-this dd { color: #b45309; }
.pv-summary .pv-bal { border-bottom: 0; padding-top: .45rem; }
.pv-summary .pv-bal dt, .pv-summary .pv-bal dd { color: var(--ink); font-weight: 700; }
.pv-summary dd.is-over { color: #dc2626 !important; }
.pv-words { margin: .7rem 0 0; font-size: .75rem; font-style: italic; color: var(--soft, #475569); }
.pv-warn { margin: .6rem 0 0; padding: .45rem .6rem; border-radius: .45rem; font-size: .72rem; color: #991b1b; background: #fef2f2; }
@media (max-width: 720px) { .pv-form { grid-template-columns: 1fr; } }

.cc-pay-row { display: flex; align-items: center; justify-content: space-between; margin-top: .35rem; }
.cc-pay { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: .4rem; font-size: .72rem; font-weight: 700; color: var(--brand);
    background: #fff; box-shadow: inset 0 0 0 1px #c7d7fe; transition: background .15s, color .15s; }
.cc-pay svg { width: .85rem; height: .85rem; }
.cc-pay:hover { background: var(--brand); color: #fff; }
.ct-rows .cc-pay-row { margin-top: .2rem; }

html.dark .pv-card { background: var(--d-surface); border-color: var(--border); border-left-color: var(--cat); }
html.dark .pv-summary { background: var(--d-surface-2); }
html.dark .pv-bar { background: rgba(148,163,184,.15); }
html.dark .pv-modes span { color: #cbd5e1; }
html.dark .pv-warn { background: rgba(220,38,38,.12); color: #fca5a5; }
html.dark .cc-pay { background: transparent; box-shadow: inset 0 0 0 1px rgba(96,140,255,.4); color: #a5c0ff; }

/* ---------- Project: slim title line (tabs other than the Deal calculator) ---------- */
.proj-slim { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.proj-slim-name { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.proj-slim-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .2rem; font-size: .8rem; color: var(--muted); }
.proj-slim-meta span + span::before { content: "·"; margin-right: 1rem; margin-left: -.5rem; color: #cbd5e1; }
.proj-slim .proj-status { color: #1e3a8a; background: #e0e9ff; }
html.dark .proj-slim .proj-status { color: #c7d7fe; background: rgba(59,110,245,.2); }

/* ---------- Deal: your build cost estimate vs cost estimation ---------- */
.cmp-card { overflow: hidden; }
.cmp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1rem 1.1rem .6rem; }
.cmp-acc { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 4.75rem; padding: .35rem .6rem; border-radius: .7rem; line-height: 1.1; background: #f1f5f9; color: #475569; }
.cmp-acc b { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cmp-acc span { font-size: .62rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.cmp-acc.is-good { background: #d1fae5; color: #047857; }
.cmp-acc.is-near { background: #fef3c7; color: #b45309; }
.cmp-acc.is-far { background: #fee2e2; color: #b91c1c; }
.cmp-tag { display: inline-flex; align-items: center; gap: .35rem; font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.cmp-tag::before { content: ""; width: .55rem; height: .55rem; border-radius: 9999px; }
.cmp-tag.is-mine::before { background: #f59e0b; }
.cmp-tag.is-est::before { background: var(--brand); }
.cmp-table td:first-child { color: var(--muted); }
.cmp-table .cmp-rate td { font-size: 1rem; font-weight: 700; color: var(--ink); }
.cmp-table .cmp-rate td:first-child { font-size: .85rem; font-weight: 600; }
.cmp-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: #f8fafc; font-size: .8rem; color: var(--muted); }
.cmp-verdict { color: var(--ink); }
.cmp-verdict.is-good { color: #047857; }
.cmp-verdict.is-near { color: #92400e; }
.cmp-verdict.is-far { color: #b91c1c; }
.cmp-spent b { color: var(--ink); }
html.dark .cmp-acc { background: rgba(148,163,184,.15); color: #cbd5e1; }
html.dark .cmp-acc.is-good { background: rgba(16,185,129,.18); color: #6ee7b7; }
html.dark .cmp-acc.is-near { background: rgba(245,158,11,.18); color: #fcd34d; }
html.dark .cmp-acc.is-far { background: rgba(239,68,68,.18); color: #fca5a5; }
html.dark .cmp-foot { background: var(--d-surface-2); border-color: var(--border); }
html.dark .cmp-verdict.is-good { color: #6ee7b7; } html.dark .cmp-verdict.is-near { color: #fcd34d; } html.dark .cmp-verdict.is-far { color: #fca5a5; }
/* contractor payments: one in process per contract */
.pv-processing { display: inline-flex; align-items: center; gap: .35rem; height: 2rem; padding: 0 .7rem; border-radius: .5rem; font-size: .75rem; font-weight: 700; white-space: nowrap;
    color: #b45309; background: #fffbeb; box-shadow: inset 0 0 0 1px #fcd34d; transition: background .15s; }
.pv-processing svg { width: .95rem; height: .95rem; }
.pv-processing:hover { background: #fef3c7; }
.pv-inprocess { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; padding: .65rem .8rem; border-radius: .6rem; font-size: .8rem; color: #92400e; background: #fffbeb; box-shadow: inset 0 0 0 1px #fcd34d; }
.pv-inprocess svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
.pv-inprocess span { flex: 1; }
.cc-pay[data-in-process] { color: #b45309; box-shadow: inset 0 0 0 1px #fcd34d; background: #fffbeb; }
.cc-pay[data-in-process]:hover { background: #f59e0b; color: #fff; }
html.dark .pv-processing, html.dark .pv-inprocess, html.dark .cc-pay[data-in-process] { color: #fcd34d; background: rgba(245,158,11,.12); box-shadow: inset 0 0 0 1px rgba(245,158,11,.4); }
/* disabled buttons look disabled */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-primary:disabled:hover { background: var(--brand); }
/* contractor payments: completed contracts, % paid */
.pv-completed { display: inline-flex; align-items: center; gap: .3rem; height: 2rem; padding: 0 .7rem; border-radius: .5rem; font-size: .75rem; font-weight: 700; color: #047857; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; white-space: nowrap; }
.pv-completed svg { width: .9rem; height: .9rem; }
.pv-progress { display: flex; flex-direction: column; gap: .3rem; padding: 0 1.1rem .7rem; }
.pv-progress .pv-bar-lg { margin-top: 0; }
.pv-progress span { font-size: .76rem; color: var(--muted); }
.pv-progress span b { color: var(--ink); font-weight: 700; }
.pv-progress span.is-full b, .pv-progress em { color: #047857; font-style: normal; font-weight: 700; }
.pv-progress small { margin-left: .3rem; color: #94a3b8; }
.pv-warn.is-done { color: #065f46; background: #ecfdf5; }
.cc-pay.is-done { color: #047857; background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; cursor: default; }
.cc-pay.is-done:hover { color: #047857; background: #ecfdf5; }
html.dark .pv-completed, html.dark .cc-pay.is-done, html.dark .pv-warn.is-done { color: #6ee7b7; background: rgba(16,185,129,.12); box-shadow: inset 0 0 0 1px rgba(16,185,129,.35); }
/* payment vouchers of one contract */
.pv-vlink { display: block; margin: .1rem 0 0 .95rem; font-size: .7rem; font-weight: 600; color: var(--brand); }
.pv-vlink:hover { text-decoration: underline; }
.pv-vf-sum { margin: -.25rem 0 .8rem; padding: .5rem .75rem; border-radius: .55rem; font-size: .8rem; color: var(--muted); background: #f8fafc; box-shadow: inset 0 0 0 1px var(--border); }
.pv-vf-sum b { color: var(--ink); }
.cc-pv-link { margin-left: .2rem; font-weight: 600; color: var(--brand); }
.cc-pv-link:hover { text-decoration: underline; }
html.dark .pv-vf-sum { background: var(--d-surface-2); }
html.dark .pv-vlink, html.dark .cc-pv-link { color: #93b4fd; }
/* spending log: % paid */
.sp-pct { margin-top: .45rem; }
.sp-pct .progress { height: .4rem; }
.sp-pct span { display: block; margin-top: .3rem; font-size: .75rem; color: var(--muted); }
.sp-pct span b { color: var(--ink); font-weight: 700; }
/* timeline: planned vs actual */
.g-plan { position: absolute; top: calc(50% + .95rem); height: .3rem; border-radius: 9999px; z-index: 1; pointer-events: auto;
    background: repeating-linear-gradient(90deg, #94a3b8 0 6px, #cbd5e1 6px 9px); opacity: .9; }
.lg.lg-baseline { width: 1.4rem !important; height: .3rem !important; border-radius: 9999px; background: repeating-linear-gradient(90deg, #94a3b8 0 6px, #cbd5e1 6px 9px) !important; border: 0 !important; }
.g-vs { display: block; font-size: .68rem; font-weight: 600; }
.g-vs.is-late { color: #dc2626; } .g-vs.is-early, .g-vs.is-ok { color: #059669; }
.tl-actual { padding: .8rem .9rem; border: 1px dashed var(--border, #e2e8f0); border-radius: .6rem; background: color-mix(in srgb, var(--brand, #1d43c0) 3%, transparent); }
.tl-actual-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .5rem; }
.tl-actual-plan { font-size: .72rem; color: var(--muted); }
.tl-actual-out { margin: .55rem 0 0; font-size: .75rem; color: #047857; font-weight: 500; }
.tl-actual-out.is-late { color: #b91c1c; }
.pva { margin-top: 1.25rem; padding: 1.1rem 1.25rem 1.25rem; }
.pva .card-head { margin-bottom: .9rem; }
.pva-empty { padding: 1rem 1.1rem; border-radius: .6rem; background: #f8fafc; font-size: .85rem; color: var(--muted); }
.pva-empty b { color: var(--ink); }
.pva-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.pva-kpis > div { padding: .75rem .9rem; border: 1px solid var(--border, #e2e8f0); border-radius: .6rem; }
.pva-kpis span { display: block; font-size: .72rem; color: var(--muted); }
.pva-kpis b { display: block; margin: .15rem 0; font-size: 1.05rem; font-weight: 700; }
.pva-kpis small { font-size: .72rem; color: var(--muted); }
.pva-tag { display: inline-block; padding: .05rem .45rem; border-radius: 9999px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.pva-tag.is-late { color: #b91c1c; background: #fef2f2; }
.pva-tag.is-early, .pva-tag.is-ok { color: #047857; background: #ecfdf5; }
.pva-tag.is-forecast { opacity: .7; font-style: italic; }
.pva-table-wrap { overflow-x: auto; }
.pva-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.pva-table th { text-align: left; padding: .45rem .6rem; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border, #e2e8f0); }
.pva-table td { padding: .55rem .6rem; border-bottom: 1px solid #f1f5f9; vertical-align: top; white-space: nowrap; }
.pva-table td small { display: block; font-size: .72rem; color: var(--muted); }
.pva-table tr.is-future td { opacity: .7; }
.pva-dot { display: inline-block; width: .55rem; height: .55rem; margin-right: .4rem; border-radius: 9999px; background: var(--c); }
.pva-lessons { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1rem; }
.pva-lesson { padding: .85rem 1rem; border-radius: .6rem; font-size: .83rem; }
.pva-lesson h4 { margin: 0 0 .35rem; font-size: .8rem; font-weight: 700; }
.pva-lesson ul { margin: 0; padding-left: 1.1rem; list-style: disc; } .pva-lesson li { margin: .2rem 0; }
.pva-lesson p { margin: 0; color: var(--muted); }
.pva-lesson.is-bad { background: #fef2f2; } .pva-lesson.is-bad h4 { color: #b91c1c; }
.pva-lesson.is-tip { background: #eff6ff; } .pva-lesson.is-tip h4 { color: #1d4ed8; }
html.dark .pva-empty { background: var(--d-surface-3); }
html.dark .pva-lesson.is-bad { background: color-mix(in srgb, #ef4444 12%, var(--d-surface)); }
html.dark .pva-lesson.is-tip { background: color-mix(in srgb, #3b82f6 12%, var(--d-surface)); }
html.dark .pva-tag.is-late { background: color-mix(in srgb, #ef4444 18%, transparent); color: #fca5a5; }
html.dark .pva-tag.is-early, html.dark .pva-tag.is-ok { background: color-mix(in srgb, #10b981 18%, transparent); color: #6ee7b7; }
html.dark .pva-table td { border-color: var(--border); }
@media (max-width: 768px) { .pva-kpis { grid-template-columns: 1fr 1fr; } .pva-lessons { grid-template-columns: 1fr; } }
/* timeline: lessons (why late / early), carried to the next projects */
.pva-note { display: block; max-width: 22rem; margin-top: .3rem; padding: .3rem .5rem; border-left: 3px solid #f59e0b; border-radius: .25rem; background: #fffbeb;
    font-size: .74rem; line-height: 1.35; color: #78350f; text-align: left; white-space: normal; cursor: pointer; }
.pva-note:hover { background: #fef3c7; }
.pva-add-note { margin-top: .3rem; font-size: .72rem; font-weight: 600; color: var(--brand, #1d43c0); }
.pva-add-note:hover { text-decoration: underline; }
.pva-why { display: block; margin-top: .1rem; font-style: italic; color: #7f1d1d; }
.tl-past { margin-top: .75rem; padding: .65rem .75rem; border-radius: .5rem; background: #fffbeb; border: 1px solid #fde68a; }
.tl-past-head { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #92400e; margin-bottom: .35rem; }
.tl-past ul { margin: 0; padding: 0; list-style: none; }
.tl-past li { padding: .3rem 0; border-top: 1px solid #fde68a; font-size: .78rem; }
.tl-past li:first-child { border-top: 0; }
.tl-past li small { color: var(--muted); }
.tl-past li p { margin: .15rem 0 0; color: #78350f; }
.pva-past { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border, #e2e8f0); }
.pva-past h4 { margin: 0; font-size: .9rem; font-weight: 700; }
.pva-past-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .75rem; }
.pva-past-card { padding: .75rem .85rem; border: 1px solid var(--border, #e2e8f0); border-left: 3px solid #f59e0b; border-radius: .5rem; font-size: .8rem; }
.pva-past-card.is-other { opacity: .75; border-left-color: #cbd5e1; }
.pva-past-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem; }
.pva-past-hint { display: block; margin-top: .35rem; color: #b45309; font-weight: 600; }
.pva-past-card ul { margin: .45rem 0 0; padding: 0; list-style: none; }
.pva-past-card li { padding: .35rem 0; border-top: 1px dashed var(--border, #e2e8f0); }
.pva-past-card li p { margin: 0; }
.pva-past-card li small { color: var(--muted); }
html.dark .pva-note, html.dark .tl-past { background: color-mix(in srgb, #f59e0b 12%, var(--d-surface)); border-color: color-mix(in srgb, #f59e0b 35%, var(--d-surface)); color: #fde68a; }
html.dark .tl-past li p, html.dark .tl-past-head { color: #fde68a; }
html.dark .tl-past li { border-color: color-mix(in srgb, #f59e0b 30%, var(--d-surface)); }
html.dark .pva-why { color: #fca5a5; }

/* =====================================================================
   Project documents (plans, maps, permits …)
   ===================================================================== */
.doc-upload { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1rem; position: relative; overflow: hidden; }
@media (min-width: 1024px) { .doc-upload { grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); align-items: stretch; } }
.doc-drop { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border: 1.5px dashed #c7d2e3; border-radius: .7rem; background: #f8fafc; cursor: pointer; transition: border-color .15s, background .15s; min-height: 5.25rem; }
.doc-drop:hover, .doc-drop.is-over { border-color: var(--brand); background: #eff4ff; }
.doc-drop:focus-within { box-shadow: 0 0 0 3px var(--brand-ring); }
.doc-drop-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; font-size: .875rem; color: var(--ink); }
.doc-drop-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-drop-text u { color: var(--brand); text-underline-offset: 2px; font-weight: 600; }
.doc-drop-text small { font-size: .72rem; color: var(--muted); line-height: 1.35; }
.doc-upload-fields { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); align-items: end; }
.doc-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #e2e8f0; }
.doc-progress i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .15s; }

.doc-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.doc-search { width: 15rem; max-width: 100%; }
.doc-group-title { display: flex; align-items: center; gap: .5rem; margin: 0 0 .7rem; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.doc-group-title span { font-size: .6875rem; padding: .05rem .45rem; border-radius: 9999px; background: #f1f5f9; letter-spacing: 0; }
.doc-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); }

.doc-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: .8rem; overflow: hidden;
    box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: box-shadow .15s, border-color .15s, transform .15s; }
.doc-card:hover { border-color: #cbd5e1; box-shadow: 0 10px 24px -14px rgba(15,23,42,.35); transform: translateY(-1px); }
.doc-thumb { position: relative; display: grid; place-items: center; height: 9.5rem; background: #f1f5f9; color: #94a3b8; border-bottom: 1px solid var(--border); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb svg { width: 3.4rem; height: 3.4rem; }
.doc-thumb:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--brand-ring); }
.doc-ext { position: absolute; top: 50%; left: 50%; transform: translate(-50%, 15%); padding: .1rem .4rem; border-radius: .3rem; font-size: .625rem; font-weight: 800; letter-spacing: .04em; color: #fff; }
.doc-k-pdf { color: #dc2626; background: #fef2f2; } .doc-k-pdf .doc-ext { background: #dc2626; }
.doc-k-cad { color: #0e7490; background: #ecfeff; } .doc-k-cad .doc-ext { background: #0e7490; }
.doc-k-doc { color: #1d4ed8; background: #eff6ff; } .doc-k-doc .doc-ext { background: #1d4ed8; }
.doc-k-xls { color: #15803d; background: #f0fdf4; } .doc-k-xls .doc-ext { background: #15803d; }
.doc-k-ppt { color: #c2410c; background: #fff7ed; } .doc-k-ppt .doc-ext { background: #c2410c; }
.doc-k-img, .doc-k-other { color: #64748b; } .doc-k-img .doc-ext, .doc-k-other .doc-ext { background: #64748b; }
.doc-body { padding: .75rem .85rem .35rem; min-width: 0; flex: 1; }
.doc-title { font-size: .9rem; font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { margin-top: .15rem; font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-notes { margin-top: .4rem; font-size: .78rem; color: #475569; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.doc-actions { display: flex; align-items: center; gap: .25rem; padding: .4rem .55rem .55rem; }
.doc-act { padding: .3rem .6rem; border-radius: .45rem; font-size: .78rem; font-weight: 600; color: var(--brand); }
.doc-act:hover { background: #eff4ff; }
.doc-icon { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: .45rem; color: #94a3b8; }
.doc-icon:hover { background: #f1f5f9; color: var(--ink); }
.doc-icon.is-danger:hover { background: #fef2f2; color: #dc2626; }
.doc-empty { padding: 3rem 1rem; text-align: center; }

html.dark .doc-drop { background: var(--d-surface-2); border-color: var(--border-strong); }
html.dark .doc-drop:hover, html.dark .doc-drop.is-over { background: rgba(59,110,245,.1); border-color: #3b6ef5; }
html.dark .doc-progress { background: var(--d-surface-3); }
html.dark .doc-card { background: var(--d-surface); border-color: var(--border); }
html.dark .doc-card:hover { border-color: var(--border-strong); }
html.dark .doc-thumb { background: var(--d-surface-2); border-color: var(--border); }
html.dark .doc-k-pdf, html.dark .doc-k-cad, html.dark .doc-k-doc, html.dark .doc-k-xls, html.dark .doc-k-ppt { background: var(--d-surface-2); }
html.dark .doc-notes { color: #a7b3c9; }
html.dark .doc-group-title span { background: var(--d-surface-3); }
html.dark .doc-act:hover { background: rgba(59,110,245,.15); }
html.dark .doc-icon:hover { background: var(--d-surface-3); }
html.dark .doc-icon.is-danger:hover { background: rgba(220,38,38,.15); color: #f87171; }

/* Material Cost: drag grip to reorder rows within a category */
.tbl.mat-table tr.cat-item td.mat-name-cell { position: relative; padding-left: 1.75rem; }
.mat-grip { position: absolute; left: .3rem; top: .6rem; display: grid; place-items: center; width: 1.25rem; height: 1.9rem; border-radius: .35rem;
    color: #cbd5e1; cursor: grab; touch-action: none; transition: color .12s, background .12s; }
.mat-grip svg { width: .95rem; height: .95rem; }
.mat-table tr.cat-item:hover .mat-grip { color: #64748b; }
.mat-grip:hover, .mat-grip:focus-visible { color: var(--brand) !important; background: #eff4ff; outline: none; }
.mat-grip:focus-visible { box-shadow: 0 0 0 3px var(--brand-ring); }
.mat-grip:active { cursor: grabbing; }
.mat-table tr.mat-ghost td { background: #eff4ff !important; opacity: .6; }
.mat-table tr.mat-chosen td { background: #f8fafc; }
html.dark .mat-grip { color: #475569; }
html.dark .mat-grip:hover, html.dark .mat-grip:focus-visible { background: rgba(59,110,245,.15); }
html.dark .mat-table tr.mat-ghost td { background: rgba(59,110,245,.15) !important; }
html.dark .mat-table tr.mat-chosen td { background: var(--d-surface-3); }

/* Spending log: filter by supplier / payee */
.sp-payee { height: 2.4rem; width: auto; max-width: 16rem; padding-top: 0; padding-bottom: 0; font-size: .875rem; }
.sp-payee.is-on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); color: var(--brand); font-weight: 600; }
.sp-payee-link { display: inline-flex; align-items: center; gap: .3rem; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.sp-payee-link:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }
.sp-payee-link:focus-visible { outline: none; color: var(--brand); box-shadow: 0 0 0 2px var(--brand-ring); border-radius: .25rem; }
html.dark .sp-payee.is-on { color: #c7d7fe; }

/* =====================================================================
   App shell: sidebar (workspace + the open project's pages) and content
   ===================================================================== */
.skip-link { position: absolute; left: -999px; top: .5rem; z-index: 100; padding: .5rem .8rem; border-radius: .5rem; background: var(--brand); color: #fff; font-weight: 600; }
.skip-link:focus { left: .5rem; }
.app { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-foot { border-top: 1px solid var(--border); background: #fff; }

.side { position: sticky; top: 0; align-self: flex-start; display: flex; flex-direction: column; width: 16.5rem; flex-shrink: 0; height: 100vh;
    background: #fff; border-right: 1px solid var(--border); z-index: 60; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem; }
.side-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: .95rem; color: var(--ink); letter-spacing: -.01em; }
.side-logo { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .55rem; background: var(--brand); color: #fff; }
.side-logo svg { width: 1.15rem; height: 1.15rem; }
.side-x { display: none; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .5rem; color: #475569; }
.side-x svg { width: 1rem; height: 1rem; }
.side-x:hover { background: #f1f5f9; }
.side-scroll { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; scrollbar-width: thin; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-h { margin: 1.1rem .65rem .35rem; font-size: .6875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #64748b; }
.side-link { display: flex; align-items: center; gap: .65rem; min-height: 2.35rem; padding: 0 .65rem; border-radius: .5rem; font-size: .875rem; font-weight: 500; color: #334155;
    transition: background .12s, color .12s; }
.side-link svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; color: #64748b; }
.side-link:hover { background: #f1f5f9; color: var(--ink); }
.side-link[aria-current="page"] { background: #eef2ff; color: var(--brand); font-weight: 600; }
.side-link[aria-current="page"] svg { color: var(--brand); }
.side-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.side-n { font-size: .6875rem; font-weight: 600; padding: .05rem .5rem; border-radius: 9999px; background: #f1f5f9; color: #475569; }
.side-n.is-warn { background: #fffaeb; color: #b54708; }
.side-proj { display: flex; align-items: center; gap: .65rem; margin: 1.1rem 0 0; padding: .6rem; border: 1px solid var(--border); border-radius: .7rem; background: #f8fafc; }
.side-proj:hover { border-color: #cbd5e1; background: #fff; }
.side-proj:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.side-proj-av { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; flex-shrink: 0; border-radius: .5rem; background: #e0e7ff; color: var(--brand); font-size: .78rem; font-weight: 700; }
.side-proj-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-proj-text b { font-size: .875rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-proj-text small { font-size: .75rem; color: #475569; }
.side-foot { display: flex; align-items: center; gap: .5rem; padding: .7rem .75rem; border-top: 1px solid var(--border); }
.side-foot .user-menu { flex: 1; min-width: 0; }
.side-foot .user-menu summary { color: #334155; padding: .3rem .4rem .3rem .3rem; }
.side-foot .user-menu summary:hover, .side-foot .user-menu[open] summary { background: #f1f5f9; }
.side-foot .user-av { box-shadow: none; }
.side-foot .user-who { flex: 1; min-width: 0; display: flex; }
.side-foot .user-who b { color: var(--ink); max-width: none; }
.side-foot .user-who small { color: #64748b; }
.side-foot .user-pop { top: auto; bottom: calc(100% + .5rem); left: 0; right: auto; }
.side-foot .theme-btn { color: #475569; background: transparent; border: 1px solid var(--border); }
.side-foot .theme-btn:hover { background: #f1f5f9; color: var(--ink); }

.side-scrim { display: none; }
.mtop { display: none; }

/* Phones and tablets: the sidebar slides in over the page */
@media (max-width: 1023.98px) {
    .side { position: fixed; left: 0; top: 0; bottom: 0; height: 100%; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 0 20px 50px -10px rgba(15,23,42,.35); }
    .side-open .side { transform: none; }
    .side-x { display: grid; }
    .side-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(15,23,42,.4); }
    .side-open .side-scrim { display: block; }
    .mtop { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .6rem; height: 3.5rem; padding: 0 .75rem; background: #fff; border-bottom: 1px solid var(--border); }
    .mtop-btn { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: .55rem; color: #334155; }
    .mtop-btn:hover { background: #f1f5f9; }
    .mtop-btn svg { width: 1.3rem; height: 1.3rem; }
    .mtop-brand { font-weight: 700; color: var(--ink); }
    .mtop-proj { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; color: #475569; }
    .mtop-proj::before { content: "/"; margin-right: .5rem; color: #cbd5e1; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

html.dark .side, html.dark .mtop, html.dark .app-foot { background: var(--d-surface); border-color: var(--border); }
html.dark .side-brand, html.dark .mtop-brand { color: var(--ink); }
html.dark .side-link { color: #cbd5e1; }
html.dark .side-link svg { color: #94a3b8; }
html.dark .side-link:hover, html.dark .side-x:hover, html.dark .mtop-btn:hover { background: var(--d-surface-3); color: var(--ink); }
html.dark .side-link[aria-current="page"] { background: rgba(59,110,245,.16); color: #c7d7fe; }
html.dark .side-link[aria-current="page"] svg { color: #c7d7fe; }
html.dark .side-h { color: #94a3b8; }
html.dark .side-n { background: var(--d-surface-3); color: #cbd5e1; }
html.dark .side-n.is-warn { background: rgba(245,158,11,.15); color: #fbbf24; }
html.dark .side-proj { background: var(--d-surface-2); border-color: var(--border); }
html.dark .side-proj:hover { background: var(--d-surface-3); border-color: var(--border-strong); }
html.dark .side-proj-av { background: rgba(59,110,245,.2); color: #c7d7fe; }
html.dark .side-proj-text small, html.dark .mtop-proj { color: #94a3b8; }
html.dark .side-foot { border-color: var(--border); }
html.dark .side-foot .user-menu summary { color: #cbd5e1; }
html.dark .side-foot .user-menu summary:hover, html.dark .side-foot .user-menu[open] summary { background: var(--d-surface-3); }
html.dark .side-foot .theme-btn { color: #cbd5e1; border-color: var(--border); }
html.dark .side-foot .theme-btn:hover { background: var(--d-surface-3); }
html.dark .mtop-btn, html.dark .side-x { color: #cbd5e1; }

/* ---------- Page header (every project page) ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-eyebrow { font-size: .8125rem; font-weight: 500; color: #475569; }
.page-title { margin: .2rem 0 0; font-size: 1.75rem; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
.page-sub { margin-top: .35rem; font-size: .875rem; color: #475569; max-width: 48rem; }
html.dark .page-eyebrow, html.dark .page-sub { color: #94a3b8; }

/* ---------- Project overview ---------- */
.ov { display: flex; flex-direction: column; gap: 1.25rem; }
.ov .page-head { margin-bottom: .25rem; }
.ov-kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr)); }
.ov-kpi { display: flex; flex-direction: column; gap: .3rem; padding: 1.1rem 1.15rem; background: #fff; border: 1px solid var(--border); border-radius: .8rem; transition: border-color .15s, box-shadow .15s; }
.ov-kpi:hover { border-color: #cbd5e1; box-shadow: 0 8px 20px -14px rgba(15,23,42,.35); }
.ov-kpi:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.ov-kpi-label { font-size: .8125rem; font-weight: 500; color: #475569; }
.ov-kpi-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.015em; color: var(--ink); line-height: 1.2; }
.ov-kpi-sub { font-size: .8125rem; color: #475569; }
.ov-kpi-sub.is-good { color: #067647; font-weight: 500; }
.ov-kpi-sub.is-warn { color: #b54708; font-weight: 500; }
.ov-kpi-sub.is-bad { color: #b42318; font-weight: 500; }
.ov-bar { display: block; height: .45rem; border-radius: 9999px; background: #eaecf0; overflow: hidden; margin-top: .3rem; }
.ov-bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.ov-bar i.is-over { background: #d92d20; }
.ov-cols { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.ov-wide { flex: 3 1 30rem; min-width: 0; }
.ov-narrow { flex: 2 1 21rem; min-width: 0; }
.ov-card { background: #fff; border: 1px solid var(--border); border-radius: .8rem; overflow: hidden; }
.ov-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.1rem; }
.ov-card-head h2 { font-size: 1rem; font-weight: 600; color: var(--ink); }
.ov-card-head span { font-size: .8125rem; color: #475569; }
.ov-card-head a { font-size: .8125rem; font-weight: 600; color: var(--brand); }
.ov-card-head a:hover { text-decoration: underline; text-underline-offset: 2px; }
.ov-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.1rem; border-top: 1px solid #eaecf0; color: var(--ink); }
a.ov-row:hover { background: #f9fafb; }
a.ov-row:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--brand-ring); }
.ov-ico { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: .55rem; }
.ov-ico svg { width: 1.1rem; height: 1.1rem; }
.ov-ico.is-warn { background: #fffaeb; color: #b54708; }
.ov-ico.is-bad { background: #fef3f2; color: #b42318; }
.ov-ico.is-info { background: #eef2ff; color: #1d43c0; }
.ov-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ov-row-text b { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-row-text small { font-size: .8125rem; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-row-right { font-size: .875rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ov-row-right.is-bad { color: #b42318; }
.ov-date { width: 2.5rem; flex-shrink: 0; text-align: center; line-height: 1.15; }
.ov-date b { display: block; font-size: .95rem; }
.ov-date small { font-size: .6875rem; text-transform: uppercase; color: #475569; }
.ov-doc { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: .5rem; font-size: .625rem; font-weight: 800; letter-spacing: .03em; }
.ov-cats { display: flex; flex-direction: column; gap: .9rem; padding: 0 1.1rem 1.1rem; }
.ov-cat-line { display: flex; justify-content: space-between; gap: .75rem; font-size: .8125rem; }
.ov-cat-line span:first-child { font-weight: 500; color: var(--ink); }
.ov-cat-line span:last-child { color: #475569; white-space: nowrap; }
.ov-cat-line .is-bad { color: #b42318 !important; font-weight: 600; }
.ov-clear { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem 1.2rem; border-top: 1px solid #eaecf0; font-size: .875rem; color: #475569; }
.ov-clear svg { width: 1.3rem; height: 1.3rem; color: #067647; flex-shrink: 0; }
.ov-empty { padding: 0 1.1rem 1.1rem; font-size: .875rem; color: #475569; }
.ov-empty a { color: var(--brand); font-weight: 600; }

html.dark .ov-kpi, html.dark .ov-card { background: var(--d-surface); border-color: var(--border); }
html.dark .ov-kpi:hover { border-color: var(--border-strong); }
html.dark .ov-kpi-label, html.dark .ov-kpi-sub, html.dark .ov-card-head span, html.dark .ov-row-text small, html.dark .ov-date small,
html.dark .ov-cat-line span:last-child, html.dark .ov-clear, html.dark .ov-empty { color: #94a3b8; }
html.dark .ov-kpi-sub.is-good { color: #4ade80; } html.dark .ov-kpi-sub.is-warn { color: #fbbf24; } html.dark .ov-kpi-sub.is-bad, html.dark .ov-row-right.is-bad, html.dark .ov-cat-line .is-bad { color: #f87171 !important; }
html.dark .ov-bar { background: var(--d-surface-3); }
html.dark .ov-row, html.dark .ov-clear { border-color: var(--border); }
html.dark a.ov-row:hover { background: var(--d-surface-3); }
html.dark .ov-ico.is-warn { background: rgba(245,158,11,.15); color: #fbbf24; }
html.dark .ov-ico.is-bad { background: rgba(220,38,38,.15); color: #f87171; }
html.dark .ov-ico.is-info { background: rgba(59,110,245,.16); color: #c7d7fe; }

/* ---------- Budget: summary strip, segmented filter, section titles ---------- */
.sum-strip { display: flex; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: .8rem; overflow: hidden; }
.sum-strip > div { flex: 1 1 13rem; display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.2rem; border-right: 1px solid var(--border); margin-right: -1px; }
.sum-strip span { font-size: .8125rem; font-weight: 500; color: #475569; }
.sum-strip b { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.sum-strip small { font-size: .75rem; color: #475569; }
.seg-filter { display: inline-flex; gap: 2px; padding: 3px; background: #f1f5f9; border: 1px solid var(--border); border-radius: .65rem; }
.seg-filter button { display: inline-flex; align-items: center; gap: .4rem; height: 2.15rem; padding: 0 .9rem; border-radius: .5rem; font-size: .875rem; font-weight: 600; color: #475569; }
.seg-filter button span { font-weight: 500; color: #64748b; }
.seg-filter button:hover { color: var(--ink); }
.seg-filter button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.seg-filter button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.sec-title { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.sec-title span { font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 9999px; background: #f1f5f9; color: #475569; }
html.dark .sum-strip { background: var(--d-surface); border-color: var(--border); }
html.dark .sum-strip > div { border-color: var(--border); }
html.dark .sum-strip span, html.dark .sum-strip small { color: #94a3b8; }
html.dark .seg-filter { background: var(--d-surface-2); border-color: var(--border); }
html.dark .seg-filter button { color: #94a3b8; }
html.dark .seg-filter button[aria-pressed="true"] { background: var(--d-surface-3); color: var(--ink); }
html.dark .sec-title span { background: var(--d-surface-3); color: #cbd5e1; }

/* ---------- Sidebar: brand, new project, project list ---------- */
.side-top { padding: 1.1rem 1rem .9rem; border-bottom: 1px solid var(--border); margin-bottom: .6rem; }
.side-logo { width: 2.25rem; height: 2.25rem; border-radius: .6rem; background: linear-gradient(135deg, #2554e0, #1b2f6e); box-shadow: 0 6px 14px -8px rgba(29,67,192,.8); }
.side-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.side-brand-text b { font-size: .95rem; font-weight: 700; }
.side-brand-text small { font-size: .72rem; font-weight: 500; color: #64748b; letter-spacing: 0; }
.side-new { display: flex; align-items: center; justify-content: center; gap: .45rem; height: 2.5rem; margin: .25rem 0 .35rem; border-radius: .6rem;
    background: var(--brand); color: #fff; font-size: .875rem; font-weight: 600; box-shadow: 0 6px 14px -8px rgba(29,67,192,.8); transition: background .15s; }
.side-new svg { width: 1rem; height: 1rem; }
.side-new:hover { background: #16359a; }
.side-new:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.side-scroll > .side-h:first-child { margin-top: .4rem; }
.side-h-row { display: flex; align-items: center; justify-content: space-between; }
.side-h-row a { font-size: .72rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--brand); }
.side-h-row a:hover { text-decoration: underline; text-underline-offset: 2px; }
.side-plink { min-height: 2.9rem; gap: .6rem; }
.side-pav { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; flex-shrink: 0; border-radius: .5rem; color: #fff; font-size: .68rem; font-weight: 700; }
.side-ptext { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.side-ptext b { font-size: .84rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-ptext small { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: #64748b; }
.side-dot { width: .45rem; height: .45rem; border-radius: 9999px; background: #94a3b8; flex-shrink: 0; }
.side-dot.is-building { background: #f79009; }
.side-dot.is-planning { background: #3b6ef5; }
.side-dot.is-completed { background: #12b76a; }
.side-empty { display: flex; flex-direction: column; gap: .25rem; margin: .2rem .15rem; padding: .85rem .9rem; border: 1px dashed #cbd5e1; border-radius: .7rem; background: #f8fafc; font-size: .78rem; color: #475569; }
.side-empty b { font-size: .84rem; color: var(--ink); }
.side-proj { margin-top: .1rem; }
html.dark .side-top { border-color: var(--border); }
html.dark .side-brand-text small, html.dark .side-ptext small { color: #94a3b8; }
html.dark .side-ptext b { color: var(--ink); }
html.dark .side-empty { background: var(--d-surface-2); border-color: var(--border-strong); color: #94a3b8; }
html.dark .side-h-row a { color: #93b4fd; }

/* =====================================================================
   Project timeline card: countdown ring + start → today → finish track
   ===================================================================== */
.ptl { background: #fff; border: 1px solid var(--border); border-radius: .9rem; padding: 1.1rem 1.25rem 1.2rem; margin-bottom: 1.25rem; }
.ptl-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.ptl-head h2 { font-size: 1rem; font-weight: 600; color: var(--ink); }
.ptl-pill { display: inline-flex; align-items: center; gap: .4rem; height: 1.6rem; padding: 0 .65rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; }
.ptl-pill i { width: .45rem; height: .45rem; border-radius: 9999px; background: currentColor; }
.ptl-pill.is-ok { background: #ecfdf3; color: #067647; }
.ptl-pill.is-warn { background: #fffaeb; color: #b54708; }
.ptl-pill.is-bad { background: #fef3f2; color: #b42318; }
.ptl-pill.is-wait { background: #eef2ff; color: #1d43c0; }
.ptl-pill.is-none { background: #f2f4f7; color: #475467; }

.ptl-body { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem 2rem; }
.ptl-ring { position: relative; width: 8.5rem; height: 8.5rem; flex-shrink: 0; }
.ptl-ring svg { width: 100%; height: 100%; }
.ptl-ring circle { fill: none; stroke-width: 10; }
.ptl-ring-bg { stroke: #eaecf0; }
.ptl-ring-fg { stroke: var(--brand); stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ptl-ring-fg.is-warn { stroke: #f79009; }
.ptl-ring-fg.is-bad { stroke: #d92d20; }
.ptl-ring-fg.is-ok { stroke: #12b76a; }
.ptl-ring-fg.is-wait { stroke: #98a2b3; }
.ptl-ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ptl-ring-text b { font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.ptl-ring-text span { margin-top: .3rem; font-size: .75rem; font-weight: 500; color: #475569; }

.ptl-main { flex: 1 1 26rem; min-width: 0; display: flex; flex-direction: column; gap: .9rem; }
.ptl-ends { display: flex; justify-content: space-between; gap: 1rem; }
.ptl-ends > div { display: flex; flex-direction: column; line-height: 1.25; }
.ptl-ends span { font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: #64748b; }
.ptl-ends b { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.ptl-ends small { font-size: .75rem; color: #64748b; }

.ptl-track-wrap { position: relative; padding-top: 1.9rem; }
.ptl-track { position: relative; height: .85rem; border-radius: 9999px; background: repeating-linear-gradient(45deg, #f2f4f7, #f2f4f7 6px, #eaecf0 6px, #eaecf0 12px); overflow: visible; }
.ptl-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 9999px; background: linear-gradient(90deg, #6f8ff5, var(--brand)); }
.ptl-fill.is-ok { background: linear-gradient(90deg, #6f8ff5, var(--brand)); }
.ptl-fill.is-warn { background: linear-gradient(90deg, #fdb022, #f79009); }
.ptl-fill.is-bad { background: linear-gradient(90deg, #f97066, #d92d20); }
.ptl-fill.is-wait { background: transparent; }
.ptl-tick { position: absolute; top: 50%; width: 2px; height: .45rem; margin-left: -1px; transform: translateY(-50%); border-radius: 2px; background: rgba(255,255,255,.85); box-shadow: 0 0 0 1px rgba(15,23,42,.06); }
.ptl-tick.is-year { height: .85rem; background: #fff; }
.ptl-cap { position: absolute; top: 50%; width: .95rem; height: .95rem; margin-top: -.475rem; border-radius: 9999px; background: #fff; border: 3px solid var(--brand); }
.ptl-cap.is-start { left: -.3rem; }
.ptl-cap.is-end { right: -.3rem; border-color: #0f172a; }
.ptl-today { position: absolute; top: 0; bottom: -.35rem; width: 0; z-index: 2; }
.ptl-today::after { content: ""; position: absolute; left: -1px; top: 1.45rem; bottom: 0; width: 2px; background: #0f172a; border-radius: 2px; }
.ptl-today span { position: absolute; top: 0; left: 0; transform: translateX(-50%); padding: .15rem .5rem; border-radius: .4rem; background: #0f172a; color: #fff;
    font-size: .7rem; font-weight: 600; white-space: nowrap; box-shadow: 0 4px 10px -4px rgba(15,23,42,.5); }
.ptl-months { position: relative; height: 1.1rem; margin-top: .4rem; }
.ptl-months span { position: absolute; top: 0; transform: translateX(-50%); font-size: .7rem; color: #64748b; white-space: nowrap; }
.ptl-months span.is-year { font-weight: 700; color: #334155; }

.ptl-work { display: grid; grid-template-columns: 5.25rem minmax(0, 1fr) 2.75rem; align-items: center; gap: .75rem; }
.ptl-work-label { font-size: .8125rem; font-weight: 500; color: #475569; }
.ptl-work-bar { position: relative; height: .5rem; border-radius: 9999px; background: #eaecf0; }
.ptl-work-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: #12b76a; }
.ptl-work-bar i.is-bad { background: #f79009; }
.ptl-work-now { position: absolute; top: -.3rem; bottom: -.3rem; width: 2px; margin-left: -1px; background: #0f172a; border-radius: 2px; opacity: .55; }
.ptl-work-val { font-size: .8125rem; font-weight: 700; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; }

.ptl-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .75rem; margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid #eaecf0; }
.ptl-stats > div { display: flex; flex-direction: column; gap: .1rem; }
.ptl-stats dt { font-size: .75rem; font-weight: 500; color: #64748b; }
.ptl-stats dd { font-size: 1.05rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.ptl-stats dd.is-bad { color: #b42318; }
.ptl-stats dd.is-good { color: #067647; }
.ptl-stats small { font-size: .75rem; color: #64748b; }
.ptl-empty { display: flex; align-items: center; gap: .9rem; padding: 1rem; border: 1px dashed #cbd5e1; border-radius: .7rem; background: #f8fafc; }
.ptl-empty svg { width: 2rem; height: 2rem; flex-shrink: 0; color: var(--brand); }
.ptl-empty div { display: flex; flex-direction: column; gap: .15rem; font-size: .875rem; color: #475569; }
.ptl-empty b { color: var(--ink); }
.ov .ptl { margin-bottom: 0; }
@media (prefers-reduced-motion: reduce) { .ptl-ring-fg { transition: none; } }
@media (max-width: 640px) { .ptl-ring { margin: 0 auto; } .ptl-months span:nth-child(even) { display: none; } }

html.dark .ptl { background: var(--d-surface); border-color: var(--border); }
html.dark .ptl-ring-bg { stroke: var(--d-surface-3); }
html.dark .ptl-ring-text span, html.dark .ptl-ends span, html.dark .ptl-ends small, html.dark .ptl-months span, html.dark .ptl-work-label,
html.dark .ptl-stats dt, html.dark .ptl-stats small, html.dark .ptl-empty div { color: #94a3b8; }
html.dark .ptl-months span.is-year { color: #cbd5e1; }
html.dark .ptl-track { background: repeating-linear-gradient(45deg, var(--d-surface-2), var(--d-surface-2) 6px, var(--d-surface-3) 6px, var(--d-surface-3) 12px); }
html.dark .ptl-cap { background: var(--d-surface); }
html.dark .ptl-cap.is-end { border-color: #e5eaf5; }
html.dark .ptl-today::after, html.dark .ptl-work-now { background: #e5eaf5; }
html.dark .ptl-today span { background: #e5eaf5; color: #1c2433; }
html.dark .ptl-tick { background: rgba(255,255,255,.35); }
html.dark .ptl-work-bar { background: var(--d-surface-3); }
html.dark .ptl-stats { border-color: var(--border); }
html.dark .ptl-stats dd.is-bad { color: #f87171; } html.dark .ptl-stats dd.is-good { color: #4ade80; }
html.dark .ptl-empty { background: var(--d-surface-2); border-color: var(--border-strong); }
html.dark .ptl-pill.is-ok { background: rgba(22,163,74,.15); color: #4ade80; }
html.dark .ptl-pill.is-warn { background: rgba(245,158,11,.15); color: #fbbf24; }
html.dark .ptl-pill.is-bad { background: rgba(220,38,38,.15); color: #f87171; }
html.dark .ptl-pill.is-wait { background: rgba(59,110,245,.16); color: #c7d7fe; }
html.dark .ptl-pill.is-none { background: var(--d-surface-3); color: #cbd5e1; }
.ptl-today.is-l span { transform: translateX(-.6rem); } .ptl-today.is-r span { transform: translateX(calc(-100% + .6rem)); }

/* =====================================================================
   Sidebar, modern look: soft tinted panel, raised active pill, quiet labels,
   and an optional icon rail (collapsed) on desktop.
   ===================================================================== */
.side { width: 16.25rem; background: #f8f9fb; border-right: 1px solid #eceef2; transition: width .18s ease; }
.side-top { border-bottom: 0; padding: 1rem .95rem .75rem; margin-bottom: 0; }
.side-logo { border-radius: .7rem; background: linear-gradient(140deg, #4f7bff 0%, #1d43c0 55%, #172f80 100%); box-shadow: 0 8px 16px -10px rgba(29,67,192,.9), inset 0 1px 0 rgba(255,255,255,.25); }
.side-scroll { padding: .25rem .7rem 1rem; }
.side-new { height: 2.4rem; margin: .1rem 0 .4rem; border-radius: .65rem; background: #fff; color: var(--ink); border: 1px solid #e4e7ec;
    box-shadow: 0 1px 2px rgba(16,24,40,.05); font-weight: 600; }
.side-new svg { color: var(--brand); }
.side-new:hover { background: #fff; border-color: #cfd4dc; box-shadow: 0 4px 10px -6px rgba(16,24,40,.25); }
.side-h { margin: 1.15rem .7rem .4rem; font-size: .66rem; font-weight: 700; letter-spacing: .09em; color: #667085; }
.side-link { position: relative; min-height: 2.25rem; padding: 0 .6rem; gap: .7rem; border-radius: .6rem; font-weight: 500; color: #344054; }
.side-link svg { width: 1.1rem; height: 1.1rem; color: #667085; transition: color .12s; }
.side-link:hover { background: rgba(16,24,40,.045); color: #101828; }
.side-link:hover svg { color: #344054; }
.side-link[aria-current="page"] { background: #fff; color: #101828; font-weight: 600;
    box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 0 0 1px rgba(16,24,40,.05); }
.side-link[aria-current="page"] svg { color: var(--brand); }
.side-link[aria-current="page"]::before { content: ""; position: absolute; left: -.7rem; top: .5rem; bottom: .5rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.side-n { background: #eaecf0; color: #344054; }
.side-proj { margin-top: .1rem; padding: .55rem .6rem; border-radius: .7rem; background: #fff; border-color: #e4e7ec; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.side-proj:hover { border-color: #cfd4dc; }
.side-proj-av { background: linear-gradient(140deg, #4f7bff, #1d43c0); color: #fff; border-radius: .55rem; }
.side-pav { border-radius: .55rem; }
.side-foot { gap: .35rem; padding: .65rem .7rem .8rem; border-top: 1px solid #eceef2; }
.side-foot .user-menu summary:hover, .side-foot .user-menu[open] summary { background: rgba(16,24,40,.05); }
.side-foot .theme-btn, .side-rail-btn { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: .6rem; border: 1px solid transparent; background: transparent; color: #475467; }
.side-foot .theme-btn:hover, .side-rail-btn:hover { background: rgba(16,24,40,.05); color: #101828; }
.side-rail-btn svg { width: 1.15rem; height: 1.15rem; }
.side-rail-btn:focus-visible, .side-foot .theme-btn:focus-visible, .side-new:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

/* ---- Icon rail (desktop only) ---- */
@media (min-width: 1024px) {
    .side-is-rail .side { width: 4.5rem; }
    .side-is-rail .side-label, .side-is-rail .side-brand-text, .side-is-rail .user-who, .side-is-rail .user-menu summary > svg:last-child {
        position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .side-is-rail .side-top { justify-content: center; padding-left: 0; padding-right: 0; }
    .side-is-rail .side-scroll { padding-left: .6rem; padding-right: .6rem; overflow: visible; }
    .side-is-rail .side-h { height: 1px; margin: .8rem .5rem; background: #e4e7ec; }
    .side-is-rail .side-h-row a { display: none; }
    .side-is-rail .side-link, .side-is-rail .side-new, .side-is-rail .side-proj { justify-content: center; padding: 0; }
    .side-is-rail .side-link { height: 2.6rem; }
    .side-is-rail .side-plink { height: 2.75rem; }
    .side-is-rail .side-link[aria-current="page"]::before { left: -.6rem; }
    .side-is-rail .side-n { position: absolute; top: .2rem; right: .2rem; min-width: 1.05rem; height: 1.05rem; padding: 0 .25rem; display: grid; place-items: center; font-size: .6rem; line-height: 1; }
    .side-is-rail .side-proj { height: 2.9rem; }
    .side-is-rail .side-empty { display: none; }
    .side-is-rail .side-foot { flex-direction: column-reverse; padding-left: .6rem; padding-right: .6rem; }
    .side-is-rail .side-foot .user-menu { flex: 0 0 auto; }
    .side-is-rail .side-foot .user-menu summary { padding: .25rem; }
    .side-is-rail .side-foot .user-pop { left: calc(100% + .6rem); bottom: 0; }
    .side-is-rail .side-rail-btn svg { transform: scaleX(-1); }
    /* Labels on hover / keyboard focus */
    .side-is-rail [data-tip]:hover::after, .side-is-rail [data-tip]:focus-visible::after {
        content: attr(data-tip); position: absolute; left: calc(100% + .7rem); top: 50%; transform: translateY(-50%); z-index: 90;
        padding: .3rem .6rem; border-radius: .45rem; background: #101828; color: #fff; font-size: .75rem; font-weight: 600; white-space: nowrap;
        box-shadow: 0 6px 16px -6px rgba(16,24,40,.5); pointer-events: none; }
    .side-is-rail .side-new, .side-is-rail .side-proj, .side-is-rail .side-rail-btn { position: relative; }
}
@media (max-width: 1023.98px) { .side-rail-btn { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

html.dark .side { background: #1f2838; border-color: var(--border); }
html.dark .side-new, html.dark .side-proj { background: var(--d-surface); border-color: var(--border); box-shadow: none; color: var(--ink); }
html.dark .side-new:hover, html.dark .side-proj:hover { border-color: var(--border-strong); background: var(--d-surface-3); }
html.dark .side-new svg { color: #93b4fd; }
html.dark .side-link:hover { background: rgba(255,255,255,.05); }
html.dark .side-link[aria-current="page"] { background: var(--d-surface-3); color: #fff; box-shadow: 0 0 0 1px var(--border-strong); }
html.dark .side-link[aria-current="page"] svg { color: #93b4fd; }
html.dark .side-link[aria-current="page"]::before { background: #6f8ff5; }
html.dark .side-n { background: var(--d-surface-3); color: #cbd5e1; }
html.dark .side-foot { border-color: var(--border); }
html.dark .side-foot .theme-btn, html.dark .side-rail-btn { color: #cbd5e1; border-color: transparent; }
html.dark .side-foot .theme-btn:hover, html.dark .side-rail-btn:hover, html.dark .side-foot .user-menu summary:hover { background: rgba(255,255,255,.06); }
html.dark .side-is-rail .side-h { background: var(--border); }
html.dark .side-is-rail [data-tip]:hover::after, html.dark .side-is-rail [data-tip]:focus-visible::after { background: #e5eaf5; color: #1c2433; }

/* ---------- Sidebar: more spacious ---------- */
.side { width: 17.5rem; }
.side-top { padding: 1.35rem 1.25rem 1.1rem; }
.side-brand { gap: .75rem; }
.side-logo { width: 2.5rem; height: 2.5rem; }
.side-logo svg { width: 1.3rem; height: 1.3rem; }
.side-brand-text b { font-size: 1rem; }
.side-brand-text small { font-size: .75rem; margin-top: .1rem; }
.side-scroll { padding: .4rem 1rem 1.5rem; }
.side-new { height: 2.75rem; margin: .2rem 0 .6rem; border-radius: .75rem; font-size: .9rem; }
.side-nav { gap: .3rem; }
.side-h { margin: 1.6rem .8rem .6rem; font-size: .68rem; }
.side-scroll > .side-h:first-child, .side-new + .side-h { margin-top: 1.1rem; }
.side-link { min-height: 2.65rem; padding: 0 .85rem; gap: .85rem; border-radius: .7rem; font-size: .9rem; }
.side-link svg { width: 1.25rem; height: 1.25rem; }
.side-link[aria-current="page"]::before { left: -1rem; top: .6rem; bottom: .6rem; }
.side-n { font-size: .72rem; padding: .1rem .55rem; }
.side-plink { min-height: 3.25rem; gap: .75rem; }
.side-pav { width: 2.15rem; height: 2.15rem; font-size: .72rem; }
.side-ptext b { font-size: .9rem; }
.side-ptext small { font-size: .75rem; margin-top: .1rem; }
.side-proj { padding: .75rem .8rem; gap: .8rem; border-radius: .85rem; margin-bottom: .3rem; }
.side-proj-av { width: 2.4rem; height: 2.4rem; font-size: .8rem; }
.side-proj-text b { font-size: .92rem; }
.side-proj-text small { font-size: .78rem; margin-top: .1rem; }
.side-empty { padding: 1rem 1.05rem; gap: .35rem; }
.side-foot { padding: .9rem 1rem 1.1rem; gap: .5rem; }
.side-foot .user-menu summary { padding: .4rem .5rem .4rem .4rem; gap: .65rem; }
.side-foot .user-av { width: 2.25rem; height: 2.25rem; }
.side-foot .user-who b { font-size: .86rem; }
.side-foot .user-who small { font-size: .72rem; }
.side-foot .theme-btn, .side-rail-btn { width: 2.5rem; height: 2.5rem; }
@media (min-width: 1024px) {
    .side-is-rail .side { width: 5rem; }
    .side-is-rail .side-scroll { padding-left: .75rem; padding-right: .75rem; }
    .side-is-rail .side-link { height: 2.85rem; }
    .side-is-rail .side-plink { height: 3rem; }
    .side-is-rail .side-link[aria-current="page"]::before { left: -.75rem; }
    .side-is-rail .side-h { margin: 1rem .6rem; }
    .side-is-rail .side-foot { padding-left: .75rem; padding-right: .75rem; }
}

/* ---------- Sidebar: workspace as an icon row inside a project (keeps the roomy sizes and still fits) ---------- */
.side-scroll { scrollbar-width: none; }
.side-scroll::-webkit-scrollbar { display: none; }   /* tiny screens can still scroll, without a bar */
/* Workspace as an icon row (inside a project) */
.side-quick { display: flex; gap: .35rem; padding: .3rem; border-radius: .8rem; background: rgba(16,24,40,.04); }
.side-qlink { position: relative; flex: 1; display: grid; place-items: center; height: 2.35rem; border-radius: .6rem; color: #475467; transition: background .12s, color .12s; }
.side-qlink svg { width: 1.15rem; height: 1.15rem; }
.side-qlink:hover { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.side-qlink:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.side-qlink:hover::after, .side-qlink:focus-visible::after {
    content: attr(data-tip); position: absolute; top: calc(100% + .4rem); left: 50%; transform: translateX(-50%); z-index: 90;
    padding: .25rem .55rem; border-radius: .4rem; background: #101828; color: #fff; font-size: .72rem; font-weight: 600; white-space: nowrap; pointer-events: none; }
html.dark .side-quick { background: rgba(255,255,255,.05); }
html.dark .side-qlink { color: #cbd5e1; }
html.dark .side-qlink:hover { background: var(--d-surface-3); color: #c7d7fe; box-shadow: none; }
html.dark .side-qlink:hover::after, html.dark .side-qlink:focus-visible::after { background: #e5eaf5; color: #1c2433; }
@media (min-width: 1024px) {
    /* Icon rail: the quick row stacks */
    .side-is-rail .side-quick { flex-direction: column; padding: .25rem; }
    .side-is-rail .side-qlink { height: 2.5rem; }
    .side-is-rail .side-qlink:hover::after, .side-is-rail .side-qlink:focus-visible::after { top: 50%; left: calc(100% + .7rem); transform: translateY(-50%); }
}
.side-proj { margin: .6rem 0 .3rem; }
.side-quick { gap: .4rem; padding: .35rem; margin-top: .2rem; } .side-qlink { height: 2.65rem; } .side-qlink svg { width: 1.25rem; height: 1.25rem; }

/* ---------- Dark mode: hover states that were still light (rows flashed white) ---------- */
html.dark .pbar:hover { background: var(--d-surface-3); }
html.dark .stat-chip:hover { background: var(--d-surface-3); border-color: var(--border-strong); }
html.dark .po-add-line:hover { background: rgba(59,110,245,.16); }
html.dark .picker-foot:hover { background: var(--d-surface-3); }
html.dark .pv-processing:hover, html.dark .pva-note:hover { background: rgba(245,158,11,.2); }
html.dark .cc-pay.is-done:hover { background: rgba(16,185,129,.2); color: #6ee7b7; }
html.dark .cc-pay[data-in-process]:hover { background: rgba(245,158,11,.3); color: #fde68a; }
html.dark .load-chip:hover { background: rgba(245,158,11,.3); color: #fde68a; }
/* Table rows: only the cells change colour on hover (never the row behind them), and muted rows stay dark */
html.dark .tbl tbody tr:hover { background: transparent; }
html.dark .tbl tr.row-muted td { background: var(--d-surface-2); color: #8b98ad; }
html.dark .tbl tr.row-muted td .font-medium { color: #a7b3c6; }
html.dark .tbl tr.row-muted:hover td { background: var(--d-surface-3); }

/* =====================================================================
   Deal calculator results: estimate vs budget, where the money goes, what if
   ===================================================================== */
.dc, .db, .dw { padding: 1.15rem 1.25rem 1.25rem; }
.dc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dc-title { font-size: 1rem; font-weight: 650; color: var(--ink); letter-spacing: -.005em; }
.dc-sub { margin-top: .2rem; font-size: .8125rem; color: #475569; max-width: 34rem; }
.dc-empty { margin-top: .9rem; padding: .9rem 1rem; border: 1px dashed #cbd5e1; border-radius: .7rem; background: #f8fafc; font-size: .875rem; color: #475569; }
.dc-empty a { color: var(--brand); font-weight: 600; }

.dc-bars { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.1rem; }
.dc-bar-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) auto; align-items: center; gap: .9rem; }
.dc-bar-label { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; font-weight: 500; color: #344054; }
.dc-key { width: .65rem; height: .65rem; border-radius: .2rem; flex-shrink: 0; }
.dc-track { height: .7rem; border-radius: 9999px; background: #f2f4f7; overflow: hidden; }
.dc-track i { display: block; height: 100%; border-radius: inherit; }
.dc-key.is-mine, .dc-track i.is-mine { background: #7a5af8; }
.dc-key.is-est, .dc-track i.is-est { background: var(--brand); }
.dc-key.is-spent, .dc-track i.is-spent { background: #12b76a; }
.dc-bar-val { font-size: .95rem; font-weight: 700; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; min-width: 7.5rem; }
.dc-bar-val small { font-size: .72rem; font-weight: 500; color: #64748b; }

.dc-verdict { display: flex; gap: .65rem; align-items: flex-start; margin-top: 1.1rem; padding: .8rem .95rem; border-radius: .7rem; font-size: .84rem; line-height: 1.5; background: #f8fafc; color: #344054; }
.dc-verdict svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; margin-top: .1rem; }
.dc-verdict.is-good { background: #ecfdf3; color: #05603a; }
.dc-verdict.is-near { background: #fffaeb; color: #93370d; }
.dc-verdict.is-far { background: #fef3f2; color: #912018; }

.dc-grid { margin-top: 1.1rem; border: 1px solid var(--border); border-radius: .75rem; overflow: hidden; }
.dc-grid-row { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); align-items: center; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid #eaecf0; font-size: .875rem; }
.dc-grid-row > span:not(:first-child) { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.dc-grid-row > span:first-child { display: flex; flex-direction: column; font-weight: 500; color: #344054; }
.dc-grid-row small { font-size: .72rem; font-weight: 400; color: #64748b; }
.dc-grid-row.is-head { border-top: 0; padding-top: .55rem; padding-bottom: .55rem; background: #f9fafb; }
.dc-grid-row.is-head > span { font-size: .72rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: #64748b !important; }
.dc-grid-row.is-total { background: #fcfcfd; }
.dc-grid-row.is-total > span:first-child { font-weight: 700; color: var(--ink); }
.dc-grid-row .is-profit { color: #067647 !important; }
.dc-grid-row .is-loss { color: #b42318 !important; }
.dc-chip { display: inline-block; padding: .1rem .5rem; border-radius: 9999px; font-size: .78rem; font-style: normal; font-weight: 600; white-space: nowrap; }
.dc-chip.is-up { background: #ecfdf3; color: #067647; }
.dc-chip.is-down { background: #fef3f2; color: #b42318; }
.dc-chip.is-zero { background: #f2f4f7; color: #475467; }

/* Where the money goes */
.db-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; }
.db-total { font-size: .8125rem; color: #475569; }
.db-total b { margin-left: .25rem; font-size: .95rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.db-stack { display: flex; height: .9rem; margin-top: 1rem; border-radius: 9999px; overflow: hidden; background: #f2f4f7; gap: 2px; }
.db-stack i { display: block; height: 100%; min-width: 3px; }
.db-dot { width: .7rem; height: .7rem; border-radius: .2rem; flex-shrink: 0; margin-top: .3rem; }
.db-stack .is-land, .db-dot.is-land { background: #7a5af8; }
.db-stack .is-build, .db-dot.is-build { background: var(--brand); }
.db-stack .is-other, .db-dot.is-other { background: #f79009; }
.db-stack .is-loan, .db-dot.is-loan { background: #667085; }
.db-dot.is-sales { background: #12b76a; }
.db-list { margin-top: .9rem; }
.db-list li, .dw-list li { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem 0; border-top: 1px solid #eaecf0; }
.db-list li:first-child, .dw-list li:first-child { border-top: 0; }
.db-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.db-text b { font-size: .875rem; font-weight: 600; color: var(--ink); }
.db-text small { font-size: .75rem; color: #64748b; margin-top: .05rem; }
.db-share { font-size: .75rem; font-weight: 600; color: #64748b; padding-top: .1rem; min-width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
.db-amt { font-size: .9rem; font-weight: 600; color: var(--ink); white-space: nowrap; min-width: 8rem; text-align: right; font-variant-numeric: tabular-nums; }
.db-list li.is-zero .db-text b, .db-list li.is-zero .db-amt { color: #98a2b3; font-weight: 500; }
.db-list li.db-sum { margin-top: .2rem; padding: .8rem .9rem; border-top: 0; border-radius: .6rem; background: #f8fafc; }
.db-list li.db-sum .db-text b, .db-list li.db-sum .db-amt { font-weight: 700; font-size: .95rem; }
.db-list li.db-sales { border-top: 0; padding-top: .9rem; }
.db-profit { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem 1.5rem; margin-top: .6rem; padding: 1rem 1.1rem; border-radius: .8rem; border: 1px solid; }
.db-profit > div { display: flex; flex-direction: column; }
.db-profit > div span { font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.db-profit > div b { font-size: 1.6rem; font-weight: 750; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.db-profit dl { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.db-profit dl div { display: flex; flex-direction: column; }
.db-profit dt { font-size: .72rem; font-weight: 500; opacity: .8; }
.db-profit dd { font-size: .95rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.db-profit.is-profit { background: #ecfdf3; border-color: #abefc6; color: #05603a; }
.db-profit.is-loss { background: #fef3f2; border-color: #fecdca; color: #912018; }

/* What if */
.dw-list { margin-top: .6rem; }
.dw-list li { align-items: center; }
.dw-profit { font-size: .9rem; font-weight: 600; color: var(--ink); min-width: 6.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.dw-profit.is-loss { color: #b42318; }
.dw-list .dc-chip { min-width: 5.5rem; text-align: center; }

@media (max-width: 640px) {
    .dc-bar-row { grid-template-columns: 1fr auto; }
    .dc-track { grid-column: 1 / -1; order: 3; }
    .dc-grid-row { grid-template-columns: minmax(0, 1fr) repeat(3, minmax(0, 1fr)); gap: .4rem; padding: .6rem .7rem; font-size: .8rem; }
    .db-amt { min-width: 0; }
}

html.dark .dc-sub, html.dark .dc-bar-label, html.dark .dc-bar-val small, html.dark .dc-grid-row small, html.dark .db-total, html.dark .db-text small, html.dark .db-share { color: #94a3b8; }
html.dark .dc-grid-row > span:first-child { color: #cbd5e1; }
html.dark .dc-track, html.dark .db-stack { background: var(--d-surface-3); }
html.dark .dc-empty { background: var(--d-surface-2); border-color: var(--border-strong); color: #94a3b8; }
html.dark .dc-verdict { background: var(--d-surface-2); color: #cbd5e1; }
html.dark .dc-verdict.is-good { background: rgba(22,163,74,.13); color: #86efac; }
html.dark .dc-verdict.is-near { background: rgba(245,158,11,.13); color: #fcd34d; }
html.dark .dc-verdict.is-far { background: rgba(220,38,38,.13); color: #fca5a5; }
html.dark .dc-grid { border-color: var(--border); }
html.dark .dc-grid-row { border-color: var(--border); }
html.dark .dc-grid-row.is-head { background: var(--d-surface-2); }
html.dark .dc-grid-row.is-head > span { color: #94a3b8 !important; }
html.dark .dc-grid-row.is-total { background: var(--d-surface-2); }
html.dark .dc-grid-row .is-profit { color: #4ade80 !important; }
html.dark .dc-grid-row .is-loss, html.dark .dw-profit.is-loss { color: #f87171 !important; }
html.dark .dc-chip.is-up { background: rgba(22,163,74,.15); color: #4ade80; }
html.dark .dc-chip.is-down { background: rgba(220,38,38,.15); color: #f87171; }
html.dark .dc-chip.is-zero { background: var(--d-surface-3); color: #cbd5e1; }
html.dark .db-list li, html.dark .dw-list li { border-color: var(--border); }
html.dark .db-list li.db-sum { background: var(--d-surface-2); }
html.dark .db-list li.is-zero .db-text b, html.dark .db-list li.is-zero .db-amt { color: #7c879b; }
html.dark .db-profit.is-profit { background: rgba(22,163,74,.13); border-color: rgba(74,222,128,.3); color: #86efac; }
html.dark .db-profit.is-loss { background: rgba(220,38,38,.13); border-color: rgba(248,113,113,.3); color: #fca5a5; }

/* ---------- Budget › Materials: category summary cards (estimate, spent; click to filter) ---------- */
.cat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cat-card { position: relative; display: flex; flex-direction: column; gap: .35rem; padding: .8rem .9rem .85rem; text-align: left; border-radius: .8rem;
    background: #fff; border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(16,24,40,.04); overflow: hidden; transition: border-color .15s, box-shadow .15s, transform .15s; }
.cat-card::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--cat, var(--brand)); }
.cat-card:hover { border-color: #cbd5e1; box-shadow: 0 8px 18px -12px rgba(16,24,40,.35); transform: translateY(-1px); }
.cat-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
.cat-card.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 8px 18px -12px rgba(29,67,192,.6); }
.cat-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cat-card-name { display: flex; align-items: center; gap: .45rem; min-width: 0; font-size: .8rem; font-weight: 600; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-card-n { flex-shrink: 0; font-size: .7rem; font-weight: 600; padding: .05rem .45rem; border-radius: 9999px; background: #f2f4f7; color: #475467; }
.cat-card-est { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cat-card-bar { display: block; height: .35rem; border-radius: 9999px; background: #eaecf0; overflow: hidden; }
.cat-card-bar i { display: block; height: 100%; border-radius: inherit; background: var(--cat, var(--brand)); }
.cat-card-bar i.is-over { background: #d92d20; }
.cat-card-sub { font-size: .72rem; color: #64748b; }
.cat-card-sub.is-over { color: #b42318; font-weight: 600; }
.cat-card.is-all { background: #f8fafc; }
.cat-card.is-all::before { background: linear-gradient(90deg, #6f8ff5, var(--brand)); }
html.dark .cat-card { background: var(--d-surface); border-color: var(--border); box-shadow: none; }
html.dark .cat-card.is-all { background: var(--d-surface-2); }
html.dark .cat-card:hover { border-color: var(--border-strong); }
html.dark .cat-card.is-on { border-color: #6f8ff5; box-shadow: 0 0 0 1px #6f8ff5; }
html.dark .cat-card-name { color: #cbd5e1; }
html.dark .cat-card-n { background: var(--d-surface-3); color: #cbd5e1; }
html.dark .cat-card-bar { background: var(--d-surface-3); }
html.dark .cat-card-sub { color: #94a3b8; }
html.dark .cat-card-sub.is-over { color: #f87171; }

/* ---------- Spending: spent by category (click to filter the log) ---------- */
.scat { padding: 1.15rem 1.25rem .9rem; }
.scat-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .6rem; }
.scat-list { display: flex; flex-direction: column; }
.scat-row { display: grid; grid-template-columns: minmax(10rem, 1.3fr) minmax(6rem, 2fr) minmax(7.5rem, auto) minmax(7.5rem, auto); align-items: center; gap: 1rem;
    width: 100%; padding: .7rem .6rem; margin: 0 -.6rem; width: calc(100% + 1.2rem); border-radius: .6rem; text-align: left; border-top: 1px solid #eaecf0; transition: background .12s, opacity .12s; }
.scat-row:first-child { border-top-color: transparent; }
.scat-row:hover { background: #f8fafc; }
.scat-row:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--brand-ring); }
.scat-row.is-on { background: #eef2ff; border-top-color: transparent; box-shadow: inset 0 0 0 1px #c7d2fe; }
.scat-list.has-pick .scat-row:not(.is-on) { opacity: .55; }
.scat-list.has-pick .scat-row:not(.is-on):hover { opacity: 1; }
.scat-name { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.scat-name b { font-size: .875rem; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scat-name small { font-size: .72rem; color: #64748b; white-space: nowrap; }
.scat-bar { display: block; height: .55rem; border-radius: 9999px; background: #f2f4f7; overflow: hidden; }
.scat-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--brand)); }
.scat-amt, .scat-est { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.scat-amt b { font-size: .9rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scat-est b { font-size: .85rem; font-weight: 700; color: #344054; font-variant-numeric: tabular-nums; }
.scat-amt small, .scat-est small { font-size: .72rem; color: #64748b; white-space: nowrap; }
.scat-est.is-over b, .scat-est.is-over small { color: #b42318; }
@media (max-width: 760px) {
    .scat-row { grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; }
    .scat-bar { grid-column: 1 / -1; order: 3; }
    .scat-est { display: none; }
}
html.dark .scat-row { border-color: var(--border); }
html.dark .scat-row:hover { background: var(--d-surface-3); }
html.dark .scat-row.is-on { background: rgba(59,110,245,.14); box-shadow: inset 0 0 0 1px rgba(147,180,253,.4); }
html.dark .scat-name small, html.dark .scat-amt small, html.dark .scat-est small { color: #94a3b8; }
html.dark .scat-est b { color: #cbd5e1; }
html.dark .scat-bar { background: var(--d-surface-3); }
html.dark .scat-est.is-over b, html.dark .scat-est.is-over small { color: #f87171; }

/* ---------- Material ratios: grouped by category ---------- */
.tbl tr.rt-head td { padding-top: .7rem; padding-bottom: .7rem; }
.tbl tr.rt-head td.rt-sub { font-weight: 700; color: var(--ink); }
.tbl tbody.rt-group + tbody.rt-group tr.rt-head td { border-top: 1px solid var(--border); }
html.dark .tbl tr.rt-head td.rt-sub { color: var(--ink); }
.cat-card-est small { font-size: .72rem; font-weight: 500; color: #64748b; } html.dark .cat-card-est small { color: #94a3b8; }

/* ---------- Orders: completing with the supplier's bill ---------- */
.po-complete-grid { display: grid; grid-template-columns: minmax(10rem, 13rem) minmax(0, 1fr); gap: .9rem; align-items: end; }
@media (max-width: 640px) { .po-complete-grid { grid-template-columns: 1fr; } }
.po-billdrop { display: flex; align-items: center; gap: .7rem; min-height: 2.6rem; padding: .55rem .8rem; border: 1.5px dashed #c7d2e3; border-radius: .6rem;
    background: #f8fafc; cursor: pointer; font-size: .84rem; color: var(--ink); transition: border-color .15s, background .15s; }
.po-billdrop:hover { border-color: var(--brand); background: #eff4ff; }
.po-billdrop:focus-within { box-shadow: 0 0 0 3px var(--brand-ring); }
.po-billdrop svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; color: var(--brand); }
.po-billdrop span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-billdrop small { color: #64748b; }
.po-billdrop.has-file { border-style: solid; border-color: #12b76a; background: #ecfdf3; }
.po-billdrop.has-file svg { color: #067647; }
.po-bill-form { display: inline-flex; }
.po-bill { color: #067647; }
html.dark .po-billdrop { background: var(--d-surface-2); border-color: var(--border-strong); }
html.dark .po-billdrop:hover { background: rgba(59,110,245,.1); border-color: #6f8ff5; }
html.dark .po-billdrop small { color: #94a3b8; }
html.dark .po-billdrop.has-file { background: rgba(22,163,74,.12); border-color: rgba(74,222,128,.45); }
html.dark .po-bill { color: #4ade80; }
.sp-bill-link { font-weight: 600; color: var(--brand); } .sp-bill-link:hover { text-decoration: underline; text-underline-offset: 2px; } html.dark .sp-bill-link { color: #93b4fd; }

/* ---------- Complete order: date + bill on one row, the note under them (the box was a 2-column grid) ---------- */
.po-log { display: flex; flex-direction: column; align-items: stretch; gap: .65rem; }
.po-log.hidden { display: none; }
.po-log > p { margin: 0; }
.po-complete-grid { grid-template-columns: minmax(10rem, 12.5rem) minmax(0, 1fr); align-items: end; }
.po-complete-grid > label { min-width: 0; }
.po-billdrop { height: 2.6rem; min-height: 0; padding: 0 .85rem; background: #fff; }
.po-billdrop span { display: block; line-height: 1.25; }
.po-billdrop small { margin-left: .25rem; font-size: .75rem; }
@media (max-width: 640px) { .po-complete-grid { grid-template-columns: 1fr; } .po-billdrop { height: auto; min-height: 2.6rem; padding: .55rem .8rem; } .po-billdrop span { white-space: normal; } }
html.dark .po-billdrop { background: var(--d-surface); }

/* ---------- Order editor: size and unit side by side ("50 kg" + "bag"), with how it reads under them ---------- */
.po-unit { display: flex; gap: .3rem; }
.po-unit .po-size { width: 5.25rem; flex-shrink: 0; }
.po-unit input:last-child { flex: 1; min-width: 3.5rem; }
.po-unit-read { display: block; min-height: 1rem; margin-top: .15rem; font-size: .7rem; font-weight: 600; color: var(--brand); white-space: nowrap; }
.po-unit-read:empty { display: none; }
.po-edit td:nth-child(3) { width: 19%; }
html.dark .po-unit-read { color: #93b4fd; }

/* ---- Overview: project status switch ---- */
.st-note-link { font-weight: 600; color: var(--brand); background: none; border: 0; padding: 0; cursor: pointer; }
.st-note-link:hover { text-decoration: underline; }
.btn-warn { background: #dc6803; color: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.15); }
.btn-warn:hover { background: #b54708; }
.btn-warn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(220,104,3,.35); }
.st-warn-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: .7rem; background: #fffaeb; color: #dc6803; border: 1px solid #fedf89; }
.st-warn-why { padding: .8rem .95rem; border-radius: .6rem; background: #fffaeb; border: 1px solid #fedf89; color: #7a2e0e; font-size: .875rem; line-height: 1.5; }
.st-warn-note { margin-top: .8rem; font-size: .8125rem; color: #475569; line-height: 1.5; }
.st-warn-list { display: grid; gap: .6rem; padding-left: 1.1rem; list-style: disc; font-size: .875rem; color: #334155; line-height: 1.5; }
.st-warn-list li::marker { color: #dc6803; }
.st-dates-note { margin-bottom: 1rem; padding: .6rem .8rem; border-radius: .55rem; background: #fffaeb; border: 1px solid #fedf89; color: #7a2e0e; font-size: .8125rem; line-height: 1.45; }
html.dark .st-warn-icon { background: rgba(220,104,3,.14); border-color: rgba(253,176,34,.35); color: #fdb022; }
html.dark .st-warn-why, html.dark .st-dates-note { background: rgba(220,104,3,.12); border-color: rgba(253,176,34,.3); color: #fde4b0; }
html.dark .st-warn-note { color: #94a3b8; }
html.dark .st-warn-list { color: #cbd5e1; }

/* ---- Overview: project stage tracker (Planning → Under construction → Completed) ----
   Planning = blue, Under construction = amber, Completed = green; the same colours as the sidebar dots. */
.st-card { margin-top: 1rem; padding: 1rem 1.25rem 1.15rem; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 1rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.st-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; margin-bottom: .9rem; }
.st-switch-label { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #64748b; }
.st-note { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .8125rem; color: #64748b; }
.st-note.is-forced { padding: .2rem .65rem; border-radius: 9999px; background: #fffaeb; border: 1px solid #fedf89; color: #b54708; font-weight: 600; }

.st-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; list-style: none; margin: 0; padding: 0; }
.st-step { position: relative; --c: #94a3b8; --soft: #f1f5f9; --ring: #e2e8f0; }
.st-step.is-planning { --c: #3b6ef5; --soft: #eef2ff; --ring: #c7d2fe; }
.st-step.is-building { --c: #f79009; --soft: #fffaeb; --ring: #fedf89; }
.st-step.is-completed { --c: #12b76a; --soft: #ecfdf3; --ring: #abefc6; }
/* the line joining one step to the next */
.st-step:not(:last-child)::after { content: ""; position: absolute; top: 2.05rem; left: calc(.75rem + 2.6rem + .4rem); right: calc(-1.5rem + .4rem); height: 3px; border-radius: 3px; background: #e2e8f0; z-index: 0; }
.st-step.is-done:not(:last-child)::after { background: var(--c); }
.st-step.is-now:not(:last-child)::after { background: linear-gradient(90deg, var(--c), #e2e8f0); }

.st-step button { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: .65rem; width: 100%; padding: .75rem; text-align: left;
  border: 1.5px solid transparent; border-radius: .85rem; background: transparent; cursor: pointer; transition: background .15s, border-color .15s; }
.st-step button:hover:not(:disabled) { background: #f8fafc; }
.st-step.is-now button { background: var(--soft); border-color: var(--ring); cursor: default; }
.st-step button:disabled { cursor: not-allowed; }
.st-step button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.st-step-dot { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 9999px; flex-shrink: 0;
  background: #fff; color: #94a3b8; border: 2px solid #e2e8f0; box-shadow: 0 0 0 4px var(--surface, #fff); }
.st-step-dot svg { width: 1.2rem; height: 1.2rem; }
.st-step.is-done .st-step-dot { background: var(--c); border-color: var(--c); color: #fff; }
.st-step.is-now .st-step-dot { background: var(--c); border-color: var(--c); color: #fff; box-shadow: 0 0 0 4px var(--soft), 0 0 0 5px var(--ring); }

.st-step-text { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.st-step-top { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.st-step-text b { font-size: .95rem; font-weight: 700; color: #475569; }
.st-step.is-now .st-step-text b { color: var(--ink); }
.st-step.is-next .st-step-text b { color: #64748b; }
.st-step-text small { font-size: .8rem; color: #64748b; line-height: 1.4; }
.st-step.is-now .st-step-text small { color: #334155; }
.st-now { font-style: normal; font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .15rem .5rem; border-radius: 9999px; background: var(--c); color: #fff; }

@media (max-width: 640px) {
  .st-steps { grid-template-columns: 1fr; gap: .35rem; }
  .st-step button { flex-direction: row; align-items: center; }
  .st-step:not(:last-child)::after { top: calc(.75rem + 2.6rem + .1rem); bottom: calc(-1.1rem + .1rem); left: calc(.75rem + 1.3rem - 1.5px); right: auto; width: 3px; height: auto; }
  .st-step.is-now:not(:last-child)::after { background: linear-gradient(180deg, var(--c), #e2e8f0); }
}

html.dark .st-card { background: var(--d-surface); border-color: var(--border); box-shadow: none; }
html.dark .st-switch-label, html.dark .st-note { color: #94a3b8; }
html.dark .st-note.is-forced { background: rgba(220,104,3,.14); border-color: rgba(253,176,34,.35); color: #fdb022; }
html.dark .st-step.is-planning { --soft: rgba(59,110,245,.14); --ring: rgba(147,180,253,.35); }
html.dark .st-step.is-building { --soft: rgba(247,144,9,.13); --ring: rgba(253,176,34,.35); }
html.dark .st-step.is-completed { --soft: rgba(18,183,106,.13); --ring: rgba(74,222,128,.35); }
html.dark .st-step:not(:last-child)::after { background: var(--border-strong); }
html.dark .st-step.is-done:not(:last-child)::after { background: var(--c); }
html.dark .st-step.is-now:not(:last-child)::after { background: linear-gradient(90deg, var(--c), var(--border-strong)); }
html.dark .st-step button:hover:not(:disabled) { background: var(--d-surface-2); }
html.dark .st-step.is-now button { background: var(--soft); border-color: var(--ring); }
html.dark .st-step-dot { background: var(--d-surface-2); border-color: var(--border-strong); color: #94a3b8; box-shadow: 0 0 0 4px var(--d-surface); }
html.dark .st-step.is-done .st-step-dot, html.dark .st-step.is-now .st-step-dot { background: var(--c); border-color: var(--c); color: #fff; }
html.dark .st-step.is-now .st-step-dot { box-shadow: 0 0 0 4px var(--soft), 0 0 0 5px var(--ring); }
html.dark .st-step-text b { color: #cbd5e1; }
html.dark .st-step.is-next .st-step-text b { color: #94a3b8; }
html.dark .st-step-text small { color: #94a3b8; }
html.dark .st-step.is-now .st-step-text small { color: #e2e8f0; }
@media (max-width: 640px) { html.dark .st-step.is-now:not(:last-child)::after { background: linear-gradient(180deg, var(--c), var(--border-strong)); } }

/* ---- Overview: Start project ---- */
.st-head-right { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .6rem 1rem; }
.st-start { height: 2.4rem; padding: 0 1.1rem; gap: .45rem; }
.st-start-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex-shrink: 0; border-radius: .7rem; background: #fffaeb; color: #f79009; border: 1px solid #fedf89; }
.st-start-compare { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; padding: .9rem 1rem; border-radius: .75rem; background: #f8fafc; border: 1px solid var(--border); color: #94a3b8; }
.st-start-compare div { display: flex; flex-direction: column; gap: .15rem; }
.st-start-compare span { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #64748b; }
.st-start-compare b { font-size: 1rem; color: var(--ink); }
.st-start-vs { margin-left: auto; font-style: normal; font-size: .78rem; font-weight: 700; padding: .25rem .65rem; border-radius: 9999px; }
.st-start-vs.is-early { background: #ecfdf3; color: #067647; }
.st-start-vs.is-late { background: #fffaeb; color: #b54708; }
.st-start-vs.is-plain { background: #f1f5f9; color: #475569; }
.st-start-list { display: grid; gap: .5rem; margin-top: 1rem; padding-left: 1.1rem; list-style: disc; font-size: .875rem; color: #334155; line-height: 1.5; }
.st-start-move { display: flex; gap: .7rem; align-items: flex-start; margin-top: 1rem; padding: .8rem .9rem; border-radius: .7rem; border: 1px solid var(--border); cursor: pointer; }
.st-start-move input { margin-top: .2rem; width: 1rem; height: 1rem; accent-color: var(--brand); flex-shrink: 0; }
.st-start-move b { display: block; font-size: .875rem; color: var(--ink); }
.st-start-move small { display: block; margin-top: .15rem; font-size: .8rem; color: #64748b; line-height: 1.45; }
html.dark .st-start-icon { background: rgba(247,144,9,.14); border-color: rgba(253,176,34,.35); color: #fdb022; }
html.dark .st-start-compare { background: var(--d-surface-2); border-color: var(--border); }
html.dark .st-start-compare span, html.dark .st-start-move small { color: #94a3b8; }
html.dark .st-start-vs.is-early { background: rgba(18,183,106,.15); color: #4ade80; }
html.dark .st-start-vs.is-late { background: rgba(247,144,9,.15); color: #fdb022; }
html.dark .st-start-vs.is-plain { background: var(--d-surface-3); color: #cbd5e1; }
html.dark .st-start-list { color: #cbd5e1; }
html.dark .st-start-move { border-color: var(--border); }
