/* BuildCRM — concrete, slab, steel and hi-vis. One signature: the building. */
:root {
  --concrete: #ECEDEA; --slab: #FFFFFF; --ink: #20242A; --steel: #5A6470; --rule: #D5D8D3;
  --hivis: #F5B400; --hivis-ink: #3A2C00; --site: #2F7D4F; --brick: #B4442F; --sky: #2D6A9F;
  --head: Bahnschrift, "DIN Alternate", "DIN 2014", "Roboto Condensed", "Arial Narrow", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --r: 4px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--body); color: var(--ink); background: var(--concrete); }
h1, h2, h3 { font-family: var(--head); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; margin-top: 1.2em; }
a { color: var(--sky); text-underline-offset: 2px; }
code { background: #f3f3f0; padding: 0 .3em; border-radius: 3px; }
:focus-visible { outline: 3px solid var(--hivis); outline-offset: 2px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--hivis); padding: .5em 1em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--steel); } .small { font-size: .85rem; } .bad { color: var(--brick); } .ok { color: var(--site); }
.pre { white-space: pre-wrap; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #C9CDD2; padding: 16px 0 32px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 1.1rem; color: inherit; text-decoration: none; }
.side .brand { color: #fff; padding: 0 18px 18px; border-bottom: 1px solid #343a42; margin-bottom: 8px; }
.logo { width: 28px; height: 28px; color: var(--hivis); flex: none; }
.nav-group { padding: 10px 0 4px; }
.nav-group > span { display: block; padding: 0 18px 4px; font-size: .75rem; color: #8B929B; }
.side nav a { display: block; padding: 7px 18px 7px 15px; color: #DDE0E3; text-decoration: none; border-left: 3px solid transparent; }
.side nav a:hover { background: #2a2f36; }
.side nav a[aria-current="page"] { border-left-color: var(--hivis); background: #2a2f36; color: #fff; font-weight: 600; }
.shell { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--slab); border-bottom: 1px solid var(--rule); }
.top .who { margin-left: auto; display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.top .who a { color: var(--ink); font-weight: 600; text-decoration: none; }
.top .who small { color: var(--steel); }
.top form { margin: 0; }
.branch-switch select, .branch-tag { font-weight: 600; }
.branch-switch select { width: auto; }
.branch-tag { background: var(--concrete); padding: 4px 10px; border-radius: var(--r); }
.menu-toggle { display: none; }
main { padding: 22px 24px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions, .row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- Surfaces ---------- */
.panel { background: var(--slab); border: 1px solid var(--rule); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
.stack { display: block; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; }
.facts > div { display: flex; flex-direction: column; min-width: 0; }
.facts span { color: var(--steel); font-size: .8rem; }
.facts b { font-weight: 600; overflow-wrap: anywhere; }
.span2, .span3 { grid-column: 1 / -1; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.cols .panel { margin: 0; }
.empty { background: var(--slab); border: 1px dashed #b9bdb6; border-radius: var(--r); padding: 36px; text-align: center; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid #b9bdb6; background: var(--slab); color: var(--ink);
  border-radius: var(--r); font: 600 .9rem var(--body); text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--hivis); border-color: #d99f00; color: var(--hivis-ink); }
.btn-primary:hover { background: #ffc21a; border-color: var(--hivis-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--steel); }
.btn-ghost:hover { background: #0000000a; border-color: transparent; color: var(--ink); }
.btn-danger { color: var(--brick); border-color: #e0b3aa; }
.btn-danger:hover { background: var(--brick); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; padding: 11px; }
form.inline { display: inline; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: .82rem; color: var(--steel); }
input, select, textarea { font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #b9bdb6; border-radius: var(--r); background: #fff; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: 2px solid var(--hivis); outline-offset: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; margin: 6px 14px 6px 0; }
.check input, td input[type=checkbox], th input[type=checkbox] { width: auto; }
fieldset.sub { border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px; margin: 0; }
fieldset.sub legend { font-family: var(--head); padding: 0 6px; }
.mini-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 10px 0 0; }
.mini-form .field { min-width: 150px; flex: 1; }
.mini-form.row .field { max-width: 280px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.inline-edit { display: inline-block; }
.inline-edit > summary, .add-box > summary { list-style: none; }
.inline-edit > summary::-webkit-details-marker, .add-box > summary::-webkit-details-marker { display: none; }
.inline-edit[open] .mini-form { background: #f8f8f6; border: 1px solid var(--rule); padding: 10px; border-radius: var(--r); min-width: 280px; }
.add-box { margin-top: 12px; } .add-box[open] > summary { margin-bottom: 10px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.w-s { max-width: 90px; }
.hp { position: absolute; left: -5000px; }

/* ---------- Flash & badges ---------- */
.flash { padding: 10px 14px; border-radius: var(--r); margin-bottom: 12px; border-left: 4px solid; background: var(--slab); }
.flash-ok { border-color: var(--site); } .flash-error { border-color: var(--brick); color: #7a2618; } .flash-info { border-color: var(--sky); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #dcefe3; color: #1d5634; } .badge-info { background: #dde9f4; color: #1f4c73; } .badge-warn { background: #fff0c2; color: #6b4d00; }
.badge-bad { background: #f6dcd6; color: #87291a; } .badge-muted { background: #e8e9e6; color: #4b525a; }

/* ---------- Tables ---------- */
.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th, .grid td { padding: 7px 9px; border-bottom: 1px solid #e6e7e3; text-align: left; vertical-align: top; }
.grid thead th { font-weight: 600; color: var(--steel); background: #f6f6f4; white-space: nowrap; }
.grid tfoot td { font-weight: 600; border-top: 2px solid var(--rule); background: #fafaf8; }
.grid .num, .grid td.num, .grid th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
input.num { text-align: right; }
.grid tr.row-bad td { background: #fbeeea; }
.grid tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--brick); }
.grid.lines td { padding: 4px; } .grid.lines input, .grid.lines select { padding: 6px 8px; }
.dt-scroll { overflow-x: auto; }
.dt-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.dt-q { max-width: 280px; }
.dt-info { color: var(--steel); font-size: .85rem; margin-left: auto; }
.dt-export { display: flex; gap: 2px; }
.dt-period { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--steel); }
.dt-period input { width: 150px; }
.dt thead th[data-sortkey] { cursor: pointer; user-select: none; }
.dt thead th[aria-sort="ascending"]::after { content: " ▲"; color: var(--ink); font-size: .7em; }
.dt thead th[aria-sort="descending"]::after { content: " ▼"; color: var(--ink); font-size: .7em; }
.dt-filters th { background: #fbfbfa; padding: 4px 5px; }
.dt-filters input, .dt-filters select { padding: 4px 6px; font-size: .82rem; min-width: 80px; }
.range { display: flex; gap: 3px; } .range input { min-width: 0; width: 50%; }
.dt-filters .range input[type=date] { min-width: 118px; }
.dt-empty { text-align: center !important; color: var(--steel); padding: 26px !important; }
.dt-pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.dt-pager select { width: auto; padding: 4px 8px; }
.dt-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.dt-pages button { min-width: 34px; }
.dt-pages button[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.dt.loading tbody { opacity: .5; }
.meter { display: inline-block; width: 60px; height: 8px; background: #e2e4e0; border-radius: 4px; vertical-align: middle; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--site); }
.clip { display: inline-block; max-width: 280px; }

/* ---------- Dashboard ---------- */
.live { font-size: .85rem; color: var(--steel); }
.live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--site); margin-right: 6px; vertical-align: 1px; }
.live.stale::before { background: var(--brick); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--slab); border: 1px solid var(--rule); border-top: 4px solid var(--ink); border-radius: var(--r); padding: 14px 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-family: var(--head); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--steel); font-size: .85rem; }
.kpi:hover { border-top-color: var(--hivis); }
.kpi-bad { border-top-color: var(--brick); } .kpi-bad b { color: var(--brick); }
.kpi b.changed { animation: tick 1.2s ease; }
@keyframes tick { from { background: #fff3c4; } to { background: transparent; } }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #eeefec; }
.list li span { color: var(--steel); white-space: nowrap; }
.list li span.bad { color: var(--brick); }
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 12px; }
.report-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); margin: 0; border-left: 4px solid var(--hivis); }
.report-card b { font-family: var(--head); font-size: 1.1rem; } .report-card span { color: var(--steel); }

/* ---------- Project page & the building ---------- */
.proj-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.building-panel { display: flex; align-items: flex-end; justify-content: center; }
.building { width: 100%; max-width: 560px; height: auto; }
.b-ground { stroke: var(--ink); stroke-width: 3; }
.b-plan { fill: none; stroke: #9ea4aa; stroke-width: 1.2; stroke-dasharray: 4 3; }
.b-work { fill: #fff3c4; stroke: #d99f00; stroke-width: 1.2; }
.b-review { fill: #d8e6f1; stroke: var(--sky); stroke-width: 1.2; }
.b-done { fill: #6d767f; stroke: var(--ink); stroke-width: 1.2; }
.b-win { fill: #ffffff66; }
.b-scaffold { fill: var(--hivis); }
.b-label { font: 600 13px var(--head); fill: var(--ink); }
.b-state { font: 12px var(--body); fill: var(--steel); }
.feed { display: grid; gap: 4px; margin-top: 14px; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid #eeefec; }
.feed-item img { width: 140px; height: 100px; object-fit: cover; border-radius: var(--r); }
.feed-item p { margin: 4px 0; }
.add-update { background: #fafaf8; border: 1px solid var(--rule); padding: 12px; border-radius: var(--r); }
.ticket { padding: 10px 0; border-top: 1px solid #eeefec; }
.ticket .reply { background: #f4f6f2; padding: 8px 10px; border-left: 3px solid var(--site); }
.totals { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; justify-content: flex-end; }
.totals div { display: flex; flex-direction: column; align-items: flex-end; }
.totals span { font-size: .8rem; color: var(--steel); } .totals b { font-variant-numeric: tabular-nums; }
.totals input { max-width: 100px; text-align: right; }
.totals .grand b { font-family: var(--head); font-size: 1.4rem; }
.features td small { display: block; color: var(--steel); font-size: .8rem; }
.features td.child { padding-left: 28px; border-left: 3px solid var(--rule); }
.features .group-row th { background: var(--concrete); font-family: var(--head); color: var(--ink); }
.features select { min-width: 140px; }
.switch { display: inline-flex; gap: 6px; align-items: center; } .switch input { width: 18px; height: 18px; accent-color: var(--site); }
.tpl { border: 1px solid var(--rule); border-radius: var(--r); margin: 0 0 12px; padding: 10px 12px; }
.tpl legend { font-weight: 600; padding: 0 6px; }
.checkin { max-width: 440px; } .checkin .big { font-family: var(--head); font-size: 1.5rem; margin: 0; }

/* ---------- Auth & installer ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.pub .auth-wrap { min-height: 60vh; }
.auth-card { background: var(--slab); border: 1px solid var(--rule); border-top: 5px solid var(--hivis); border-radius: var(--r); padding: 26px; width: 100%; max-width: 400px; display: grid; gap: 14px; }
.auth-card.wide { max-width: 760px; }
.auth-card .brand { color: var(--ink); } .auth-card h1 { margin: 0; } .auth-card p { margin: 0; }
.checks { list-style: none; padding: 0; margin: 0; columns: 2; font-size: .85rem; }
.checks .ok::before { content: "● "; color: var(--site); } .checks .bad::before { content: "● "; color: var(--brick); }

/* ---------- Public: portal & showcase ---------- */
.pub-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px clamp(16px, 4vw, 48px); background: var(--ink); }
.pub-top .brand { color: #fff; } .pub-top nav { display: flex; gap: 8px; align-items: center; } .pub-top form { margin: 0; }
.pub-top .btn-ghost { color: #dde0e3; }
.pub-main { max-width: 1100px; margin: 0 auto; padding: 24px clamp(14px, 4vw, 32px) 60px; }
.pub-foot { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; padding: 22px; color: var(--steel); font-size: .85rem; border-top: 1px solid var(--rule); }
.portal-hello { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.alert { padding: 12px 16px; border-radius: var(--r); margin-bottom: 10px; font-size: 1rem; }
.alert-warn { background: #fff3c4; border-left: 5px solid var(--hivis); }
.alert-bad { background: #f8dfd8; border-left: 5px solid var(--brick); }
.portal-hero { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: end; background: var(--slab); border: 1px solid var(--rule); border-radius: var(--r); padding: 22px; margin-bottom: 16px; }
.big-num { font-family: var(--head); font-size: clamp(3rem, 9vw, 5.5rem); line-height: 1; margin: .2em 0; font-weight: 600; }
.big-num small { font-size: 1rem; color: var(--steel); margin-left: 6px; font-family: var(--body); font-weight: 400; }
.timeline { list-style: none; margin: 0; padding: 0; counter-reset: st; }
.timeline li { position: relative; padding: 6px 0 14px 34px; counter-increment: st; display: flex; flex-direction: column; }
.timeline li::before { content: counter(st); position: absolute; left: 0; top: 4px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #9ea4aa; font-size: .72rem; display: grid; place-items: center; background: #fff; }
.timeline li::after { content: ""; position: absolute; left: 11px; top: 28px; bottom: 0; width: 2px; background: #d2d5d0; }
.timeline li:last-child::after { display: none; }
.timeline span { color: var(--steel); font-size: .88rem; }
.timeline .t-approved::before { background: var(--ink); border-color: var(--ink); color: #fff; }
.timeline .t-completed::before { border-color: var(--sky); color: var(--sky); }
.timeline .t-in_progress::before { background: var(--hivis); border-color: #d99f00; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; } .gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r); display: block; }
.gallery figcaption { font-size: .8rem; color: var(--steel); padding-top: 4px; }
.gallery.big { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-bottom: 18px; }
.show-hero { padding: 26px 0 20px; max-width: 64ch; }
.show-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.show-hero p { font-size: 1.1rem; color: var(--steel); }
.show-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 26px; }
.show-card { background: var(--slab); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; }
.show-card img, .show-ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #f3f3f0; }
.show-ph { display: flex; align-items: flex-end; justify-content: center; padding: 14px; }
.show-card > div:last-child { padding: 12px 14px; display: flex; flex-direction: column; }
.show-card b { font-family: var(--head); font-size: 1.1rem; } .show-card span { color: var(--steel); font-size: .88rem; }
.show-card:hover { border-color: var(--ink); }
.enquiry { border-top: 5px solid var(--hivis); }

/* ---------- Documents & print ---------- */
.print-body { background: #fff; padding: 24px; max-width: 1100px; margin: 0 auto; }
.print-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.print-head p { color: var(--steel); margin: 0; }
.doc { max-width: 820px; }
.doc-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 3px solid var(--ink); padding-bottom: 12px; margin-bottom: 16px; }
.doc-head > div:first-child { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; align-items: center; }
.doc-head > div:first-child b { font-family: var(--head); font-size: 1.3rem; }
.doc-head small { grid-column: 2; color: var(--steel); }
.doc-head .logo { color: var(--ink); grid-row: span 2; }
.doc-kind { text-align: right; display: flex; flex-direction: column; }
.doc-kind b { font-family: var(--head); font-size: 1.3rem; }
.doc-to { margin-bottom: 14px; }
.receipt-line { font-size: 1.05rem; line-height: 1.8; }
.sign { display: flex; justify-content: space-between; margin-top: 60px; color: var(--steel); }
.sign span { border-top: 1px solid var(--steel); padding-top: 4px; min-width: 180px; text-align: center; }
.slip { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.net { font-size: 1.2rem; margin-top: 16px; }

@media print {
  .no-print, .side, .top, .page-head .actions, .dt-bar, .dt-filters, .dt-pager, .add-box, .mini-form, .row-actions, .inline-edit, .add-update { display: none !important; }
  .app { display: block; } main { padding: 0; } .panel { border: 0; padding: 0; }
  body, .print-body { background: #fff; font-size: 12px; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax #0006; }
  .menu-toggle { display: inline-flex; }
  .top { padding: 8px 12px; flex-wrap: wrap; } main { padding: 16px 12px 50px; }
  .proj-top, .portal-hero, .slip { grid-template-columns: 1fr; }
  .top .who small { display: none; }
  .feed-item { flex-direction: column; } .feed-item img { width: 100%; height: auto; }
  .checks { columns: 1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* =====================================================================
   Rich UI layer — icon sidebar, collapsible rail, avatar bar, KPI tiles
   ===================================================================== */
:root { --line: #D5D8D3; --line-2: #C3C6BF; --ok: #2F7D4F; --ok-soft: #E3F1E8; --bad: #B4442F; --bad-soft: #F8E6E2;
  --warn: #8A5A00; --warn-soft: #FFF1CC; --hivis-soft: #FFF1CC; --info: #2D6A9F; --info-soft: #E3EDF6; --done: #4A525C;
  --r: 8px; --side: 252px; --side-mini: 76px; --shadow: 0 1px 2px rgba(20, 24, 28, .05), 0 6px 18px rgba(20, 24, 28, .05); }
body.app { background: #EDEFEB; }
.ico { width: 20px; height: 20px; flex: none; }

/* Sidebar */
.app { grid-template-columns: var(--side) 1fr; transition: grid-template-columns .2s ease; }
.side { background: #1A1E23; padding: 16px 0 12px; display: flex; flex-direction: column; border-right: 1px solid #0F1215; }
.side .brand { padding: 2px 18px 16px; gap: 12px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: var(--hivis); display: grid; place-items: center; flex: none; }
.brand-mark .logo { width: 24px; height: 24px; color: var(--ink); }
.brand-name { font-size: 1.05rem; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-search { display: flex; align-items: center; gap: 8px; margin: 0 14px 8px; padding: 0 10px; background: #252A31; border: 1px solid #2E343C; border-radius: 8px; color: #8C939C; }
.nav-search .ico { width: 16px; height: 16px; }
.nav-search input { background: transparent; border: 0; color: #fff; padding: 8px 0; font-size: .9rem; }
.nav-search input:focus { outline: none; }
.nav-search:focus-within { border-color: var(--hivis); }
.side nav { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.nav-group { padding: 4px 0 6px; }
.nav-label { display: block; padding: 12px 24px 4px; font-size: .76rem; color: #7E8691; letter-spacing: .02em; }
.side nav a { display: flex; align-items: center; gap: 12px; margin: 1px 10px; padding: 8px 12px; border-left: 0; border-radius: 8px; color: #C5CAD1; position: relative; font-size: .93rem; }
.side nav a .ico { color: #8C939C; transition: color .15s; }
.side nav a:hover { background: #252A31; color: #fff; } .side nav a:hover .ico { color: #fff; }
.side nav a[aria-current="page"] { background: rgba(245, 180, 0, .13); color: #fff; font-weight: 600; }
.side nav a[aria-current="page"] .ico { color: var(--hivis); }
.side nav a[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0; background: var(--hivis); }
.side-foot { padding: 10px 24px 0; border-top: 1px solid #2A2F36; font-size: .75rem; color: #6B727B; }

/* Collapsed icon rail (desktop) */
body.side-mini { grid-template-columns: var(--side-mini) 1fr; }
body.side-mini .brand-name, body.side-mini .nav-search, body.side-mini .side nav a span, body.side-mini .side-foot span { display: none; }
body.side-mini .side .brand { justify-content: center; padding: 2px 0 16px; }
body.side-mini .nav-label { font-size: 0; padding: 8px 0; margin: 6px 20px 2px; border-top: 1px solid #2A2F36; }
body.side-mini .side nav a { justify-content: center; padding: 10px 0; }
body.side-mini .collapse-toggle .ico { transform: scaleX(-1); }

/* Top bar */
.top { height: 62px; gap: 10px; padding: 0 22px; border-bottom: 1px solid #E0E2DD; box-shadow: 0 1px 0 rgba(20, 24, 28, .02); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; background: #fff; color: var(--ink); border: 1px solid #DDE0DA; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--concrete); border-color: var(--line-2); }
.branch-switch label, .branch-tag { display: inline-flex; align-items: center; gap: 8px; color: var(--steel); }
.branch-switch select { border-radius: 8px; min-width: 190px; font-weight: 600; color: var(--ink); }
.branch-tag { font-weight: 600; color: var(--ink); } .branch-tag .ico { color: var(--steel); }
.top .who { margin-left: auto; flex-direction: row; align-items: center; gap: 10px; text-align: left; text-decoration: none; color: var(--ink); padding: 4px 10px 4px 4px; border-radius: 999px; }
.top .who:hover { background: var(--concrete); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--ink); color: var(--hivis); display: grid; place-items: center; font: 600 .9rem var(--head); flex: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.2; } .who-text b { font-weight: 600; font-size: .92rem; } .who-text small { color: var(--steel); font-size: .78rem; }

/* Page */
main { padding: 26px 28px 60px; }
.page-head { margin-bottom: 20px; } .page-head h1 { font-size: 1.85rem; }
.panel { border-radius: 10px; border-color: #E0E2DD; box-shadow: var(--shadow); padding: 20px; }
.panel h2 { display: flex; align-items: center; gap: 8px; } .panel h2 .ico { color: var(--steel); }
.btn { border-radius: 8px; } .btn-lg { padding: 12px 18px; font-size: 1rem; }
.btn-primary { box-shadow: 0 1px 0 rgba(0, 0, 0, .06); }
input, select, textarea { border-radius: 8px; }

/* KPI tiles */
.kpis { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { flex-direction: row; align-items: center; gap: 14px; padding: 16px; border: 1px solid #E0E2DD; border-top: 1px solid #E0E2DD; border-radius: 10px; box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.kpi:hover { transform: translateY(-1px); border-color: var(--line-2); }
.kpi-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kpi-ico .ico { width: 22px; height: 22px; }
.kpi .kpi-body { display: flex; flex-direction: column; min-width: 0; color: var(--ink); font-size: 1rem; }
.kpi .kpi-body > span { color: var(--steel); font-size: .86rem; }
.kpi-ico { color: var(--ink); }
.kpi-body b { font-size: 1.5rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-ink .kpi-ico { background: #E4E7EA; color: var(--ink); } .kpi-ok .kpi-ico { background: var(--ok-soft); color: var(--ok); }
.kpi-warn .kpi-ico { background: var(--hivis-soft); color: var(--warn); } .kpi-info .kpi-ico { background: var(--info-soft); color: var(--info); }
.kpi-bad .kpi-ico { background: var(--bad-soft); color: var(--bad); } .kpi-bad b { color: var(--bad); }

/* Tables, badges, flash */
.dt { border-radius: 10px; box-shadow: var(--shadow); border-color: #E0E2DD; overflow: hidden; }
.grid tbody tr:hover td { background: #FAFAF6; } .grid tr.row-bad:hover td { background: #F4DCD6; }
.grid thead th { background: #F4F5F2; color: #3A4048; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.flash { display: flex; align-items: flex-start; gap: 10px; border-radius: 8px; border-left-width: 4px; }
.flash-ico { width: 20px; height: 20px; margin-top: 1px; }
.flash-ok .flash-ico { color: var(--ok); } .flash-error .flash-ico { color: var(--bad); } .flash-info .flash-ico { color: var(--info); }
.tabs a { border-radius: 6px 6px 0 0; } .tabs a:hover { background: #F4F5F2; color: var(--ink); }
.list li { flex-wrap: wrap; align-items: baseline; column-gap: 16px; row-gap: 2px; }
.list li a { font-weight: 500; flex: 1 1 220px; min-width: 0; }

/* Login: blueprint side + form */
.login { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.login-art { background-color: #1A1E23; background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px); background-size: 28px 28px; color: #fff; padding: 36px 44px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.login-art .brand { color: #fff; padding: 0; }
.login-building { max-width: 440px; width: 100%; margin: 0 auto; }
.login-art .b-ground { stroke: #fff; } .login-art .b-done { fill: #5E6875; } .login-art .b-plan { stroke: #59616B; }
.login-art .b-work { fill: transparent; } .login-art .b-review { fill: var(--hivis); stroke: none; } .login-art .b-scaffold { fill: #59616B; }
.login-art p { font-family: var(--head); font-size: 1.6rem; line-height: 1.25; max-width: 400px; margin: 0; }
.login-form { display: grid; place-items: center; padding: 24px; background: var(--concrete); }
.login-form .auth-card { box-shadow: var(--shadow); border-radius: 12px; border-top-width: 6px; padding: 32px; max-width: 420px; }
.login-form h1 { margin-bottom: 0; }

@media (max-width: 900px) {
  .app, body.side-mini { grid-template-columns: 1fr; }
  .collapse-toggle { display: none; }
  .menu-toggle { display: inline-grid; }
  .side { width: 270px; }
  body.side-mini .brand-name, body.side-mini .side nav a span, body.side-mini .nav-search { display: revert; }
  .who-text { display: none; }
  .branch-switch select { min-width: 0; max-width: 150px; }
  .top { padding: 0 12px; height: 58px; flex-wrap: nowrap; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 24px; } .login-building { max-width: 220px; } .login-art p { font-size: 1.2rem; }
}
@media (min-width: 901px) { .menu-toggle { display: none; } }
/* Action cells stay real table cells so row borders line up */
td.row-actions { display: table-cell; white-space: nowrap; }
td.row-actions > form, td.row-actions > a, td.row-actions > details { display: inline-block; margin: 2px 4px 2px 0; vertical-align: middle; }
.dt-filters .range { display: flex; flex-direction: column; gap: 4px; }
.dt-filters input[type=date] { width: 132px; min-width: 132px; }
.dt-filters input[type=number] { width: 88px; min-width: 70px; }
.dt tbody td { padding-top: 10px; padding-bottom: 10px; }

/* ---------- Basic + advanced search ---------- */
.dt-qwrap { display: flex; align-items: center; gap: 8px; padding: 0 10px; background: #fff; border: 1px solid var(--line-2); border-radius: 8px; flex: 0 1 320px; color: var(--steel); }
.dt-qwrap:focus-within { border-color: var(--ink); outline: 2px solid var(--hivis); }
.dt-qwrap .ico { width: 17px; height: 17px; } .dt-qwrap .dt-q { border: 0; padding: 8px 0; max-width: none; } .dt-qwrap .dt-q:focus { outline: none; }
.dt-adv-toggle .ico { width: 17px; height: 17px; }
.dt-adv-toggle.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.dt-count { background: var(--hivis); color: var(--ink); border-radius: 10px; padding: 0 7px; font-size: .78rem; line-height: 1.5; }
.dt-adv { border-bottom: 1px solid var(--line); background: #FAFAF7; padding: 14px 16px; }
.dt-adv-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 600; }
.dt-adv-head select { width: auto; display: inline-block; margin: 0 4px; padding: 4px 8px; }
.dt-adv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 8px 16px; }
.dt-adv-row { display: grid; grid-template-columns: 100px 140px minmax(0, 1fr) 32px; gap: 8px; align-items: start; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; }
.dt-adv-row.on { background: #fff; border-color: var(--hivis); }
.dt-adv-label { font-weight: 600; font-size: .9rem; padding-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-adv-row select, .dt-adv-row input { padding: 6px 8px; font-size: .9rem; }
.dt-adv-vals { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.dt-adv-vals { flex-wrap: nowrap; }
.dt-adv-vals > * { flex: 1 1 60px; min-width: 0; }
.dt-adv-vals [data-vs] { flex-basis: 100%; }
.dt-adv-vals .dt-and { flex: 0 0 auto; color: var(--steel); font-size: .85rem; }
.dt-adv-vals [hidden] { display: none !important; }
.dt-adv-row .icon-btn { width: 32px; height: 32px; font-size: 1.2rem; line-height: 1; color: var(--steel); }
.dt-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px; }
.dt-chips:not(:empty) { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--hivis-soft); border: 1px solid #F0D27A; color: var(--ink); font: 500 .85rem var(--body); cursor: pointer; }
.chip span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .08); font-size: .9rem; }
.chip:hover span { background: var(--ink); color: #fff; }
.dt-filters input::placeholder { color: #9AA0A6; }
.dt-filters th { vertical-align: top; }
.dt-filters input, .dt-filters select { width: 100%; min-width: 96px; }
@media (max-width: 900px) { .dt-adv-grid { grid-template-columns: 1fr; } .dt-adv-row { grid-template-columns: 1fr 1fr 32px; } .dt-adv-label { grid-column: 1 / -1; padding-top: 0; } .dt-adv-row [data-op] { grid-column: 1 / 3; grid-row: 2; } .dt-adv-row .dt-row-clear { grid-column: 3; grid-row: 2; } .dt-adv-vals { grid-column: 1 / -1; } .dt-qwrap { flex: 1 1 100%; } }
