/* ---------------------------------------------------------------------
   Plan Review — company dashboard

   A tool people sit in front of all day. Dense, quiet, high contrast,
   nothing that moves unless it means something.
   --------------------------------------------------------------------- */

:root {
    --primary:        #14507a;
    --primary-dark:   #0d3a5a;
    --primary-soft:   #d2e4f6;

    --bg:             #f6f7f9;
    --surface:        #ffffff;
    --border:         #dfe3e8;
    --border-strong:  #c3cad3;

    --text:           #1a1c1e;
    --text-muted:     #5f6772;

    --neutral:        #5f6672;  --neutral-bg: #e9ebef;
    --pending:        #8a5a00;  --pending-bg: #fff0d4;
    --progress:       #14507a;  --progress-bg:#d9e8f7;
    --success:        #1b6b3a;  --success-bg: #d6f0e0;
    --problem:        #ba1a1a;  --problem-bg: #ffdfdc;

    --radius:         10px;
    --shadow:         0 1px 2px rgba(16, 24, 40, .06),
                      0 1px 3px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; }

/*
 * The browser's own [hidden] rule is display:none at the lowest possible
 * specificity, so any class rule that sets display beats it. .signin is
 * display:grid and #app is display:flex, which meant the hidden attribute
 * did nothing to either: after signing in, the sign-in card stayed on
 * screen and the dashboard was pushed below the fold.
 *
 * Every assertion in the smoke test passed while this was broken — the DOM
 * was correct, only the pixels were wrong. It took a screenshot to see it.
 */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
     color: var(--primary); }

a { color: var(--primary); }
.muted { color: var(--text-muted); }
.error { color: var(--problem); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* --- sign in --- */

.signin {
    display: grid;
    place-items: center;
    min-height: 100%;
    padding: 24px;
}

.signin-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}

.signin-card h1 { margin-bottom: 2px; }
.signin-card p  { margin: 0 0 24px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 14px 0 5px;
}

input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 7px;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary-soft);
    border-color: var(--primary);
}

textarea { resize: vertical; min-height: 72px; }

/* --- buttons --- */

button {
    font: inherit;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    padding: 8px 14px;
    cursor: pointer;
}

button:hover:not(:disabled) { background: #f2f4f7; }
button:disabled { opacity: .5; cursor: not-allowed; }

button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 500;
}
button.primary:hover:not(:disabled) { background: var(--primary-dark); }

button.danger { color: var(--problem); border-color: #f0c4c0; }
button.block  { width: 100%; margin-top: 20px; padding: 10px; }
button.small  { padding: 5px 10px; font-size: 13px; }

button.link {
    border: 0; background: none; padding: 0;
    color: var(--primary); text-decoration: underline; cursor: pointer;
}

/* --- layout --- */

#app { display: flex; min-height: 100%; }

.sidebar {
    width: 210px;
    flex: 0 0 210px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.brand {
    font-weight: 700;
    font-size: 15px;
    padding: 0 20px 20px;
    color: var(--primary);
}

.sidebar nav { display: flex; flex-direction: column; }

.badge { color: var(--text-muted); font-size: 12px; font-weight: 600; }

.sidebar nav a.active .badge { color: var(--primary); }

.sidebar nav a {
    padding: 9px 20px;
    color: var(--text);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover  { background: #f2f4f7; }
.sidebar nav a.active {
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
    background: #f2f6fa;
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.who { display: block; color: var(--text-muted); margin-bottom: 6px; word-break: break-word; text-decoration: none; }
.who:hover { color: var(--text, inherit); text-decoration: underline; }

main { flex: 1; padding: 28px 32px; max-width: 1100px; }

.loading { color: var(--text-muted); padding: 40px 0; }

/* --- page furniture --- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.crumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}

.card-head {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.empty { padding: 28px 18px; color: var(--text-muted); text-align: center; }

/* --- tables --- */

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}

td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f7f9fb; }

/* --- status pills --- */

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.pill.neutral  { color: var(--neutral);  background: var(--neutral-bg); }
.pill.pending  { color: var(--pending);  background: var(--pending-bg); }
.pill.progress { color: var(--progress); background: var(--progress-bg); }
.pill.success  { color: var(--success);  background: var(--success-bg); }
.pill.problem  { color: var(--problem);  background: var(--problem-bg); }

/* --- tabs --- */

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.tabs button {
    border: 0;
    background: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 9px 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.tabs button:hover { background: none; color: var(--text); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- detail lists --- */

.facts { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; }
.facts dt { color: var(--text-muted); font-size: 13px; }
.facts dd { margin: 0; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .fixed { flex: 0 0 auto; min-width: 0; }

.checks { display: grid; gap: 10px; }

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.check input { width: auto; }
.check .grow { flex: 1; }

.note {
    background: #f2f6fa;
    border-left: 3px solid var(--primary);
    padding: 11px 14px;
    border-radius: 0 7px 7px 0;
    margin-bottom: 16px;
    font-size: 13px;
}

.note.warn { background: var(--pending-bg); border-left-color: var(--pending); }

.comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.log { list-style: none; margin: 0; padding: 0; }
.log li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log .meta { font-size: 12px; color: var(--text-muted); }

/* --- toast --- */

.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1c1e;
    color: #fff;
    padding: 11px 18px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 520px;
    z-index: 50;
}

.toast.bad { background: #7a1512; }

/* --- live alerts --- */

.alerts {
    position: fixed;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 60;
    max-width: 360px;
}

.alert-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    color: #1a1c1e;
    border-left: 4px solid #9a5f0f;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
}

.alert-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.alert-body span { color: #5a5d61; font-size: 13px; overflow-wrap: anywhere; }
.alert-actions { display: flex; align-items: center; gap: 6px; }

.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
}
.live-dot.on  { background: #2e7d32; }
.live-dot.off { background: #9aa0a6; }

@media (max-width: 760px) {
    #app { flex-direction: column; }
    .sidebar { width: auto; flex: none; flex-direction: row; align-items: center;
               padding: 10px 14px; gap: 14px; }
    .sidebar nav { flex-direction: row; }
    .badge { color: var(--text-muted); font-size: 12px; font-weight: 600; }

.sidebar nav a.active .badge { color: var(--primary); }

.sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; }
    .sidebar nav a.active { border-left: 0; border-bottom-color: var(--primary); }
    .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
    .who { display: none; }
    main { padding: 18px 14px; }
    .facts { grid-template-columns: 1fr; gap: 2px 0; }
    .facts dd { margin-bottom: 10px; }
}

/* --- staff removal ------------------------------------------------------
 * The checkbox column is deliberately narrow and unlabelled: it is not a
 * property of the person, it is a pointer at them.
 */
th.tick, td.tick { width: 2.25rem; padding-right: 0; text-align: center; }

/* The global input rule sets width:100%, which stretches a checkbox into a
 * band across the column. Checkboxes want their intrinsic size. */
td.tick input[type=checkbox] {
    width: auto;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.table-foot {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}
.table-foot .muted { flex: 1; min-width: 16rem; font-size: .8rem; line-height: 1.4; }
.table-foot button:disabled { opacity: .45; cursor: not-allowed; }

/* --- refresh -------------------------------------------------------------
 * Nothing pushes changes to an open page, so this is how you ask again.
 * Sits under the nav rather than in a page header: it belongs to the app,
 * not to whichever view happens to be on screen.
 */
.sidebar-tools { padding: 14px 20px 0; }
.sidebar-tools button { width: 100%; }

/* A note under a control, tied to it rather than floating in the card. */
.assign-note { margin: 0 0 18px; font-size: 12px; }

/* --- filings checklist --------------------------------------------------- */

/* The file input sits inside a table row next to its button, so it must not
 * take the global input width:100% and push the button off the line. */
input.inline-file {
    width: auto;
    max-width: 190px;
    padding: 3px;
    font-size: 12px;
    vertical-align: middle;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* --- staff editing and inspection triage --------------------------------- */

tr.editing td { background: var(--primary-soft); }

/* .check is a <label>, which is bold and small by default; its explanation
   underneath should read as body text. */
.check .muted { font-weight: 400; }

/* A checkbox inside .check keeps its own size, not the global input width. */
.check input[type=checkbox] { width: auto; accent-color: var(--primary); }

/* Triage: a category, then its inspection stages indented beneath it. */
.triage-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.triage-group .check { border: 0; border-radius: 0; }
.triage-group .check.category { background: #fafbfc; font-weight: 600; }
.triage-stages { padding: 4px 12px 10px 38px; display: grid;
                 grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 14px; }
.triage-stages .check { padding: 6px 0; font-weight: 400; }
.triage-stages .check .muted { font-size: 12px; }
.triage-group.off .triage-stages { opacity: .55; }

/* --- inspections: evidence review --------------------------------------- */

.ev-item { border-top: 1px solid var(--border); padding: 12px 0; }
.ev-item:first-of-type { border-top: 0; padding-top: 0; }
.ev-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ev-head .muted { font-size: 12px; }
.ev-help { font-size: 12px; margin-top: 2px; }
.ev-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 10px; margin-top: 10px; }
.ev-file { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border);
           border-radius: 8px; padding: 8px; background: var(--surface); }
.ev-thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 6px; flex: none;
            background: var(--neutral-bg); cursor: zoom-in; }
.ev-kind { display: grid; place-items: center; font-size: 12px; color: var(--text-muted); }
.ev-meta { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12px; }
.ev-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.insp-decide { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.insp-more { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.insp-more summary { cursor: pointer; color: var(--primary); font-weight: 500; }

/* --- certificate of compliance ------------------------------------------- */

.coc-steps { list-style: none; margin: 0; padding: 0; }
.coc-step { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.coc-step:last-child { border-bottom: 0; }
.coc-mark { flex: none; width: 22px; height: 22px; border-radius: 50%;
            border: 2px solid var(--border); display: flex; align-items: center;
            justify-content: center; font-size: 12px; font-weight: 700; }
.coc-step.done .coc-mark { background: var(--success); border-color: var(--success); color: #fff; }
.coc-step.current .coc-mark { border-color: var(--pending); }
.coc-step:not(.done):not(.current) > div > strong { color: var(--neutral); }
.coc-body { margin-top: 6px; }
.coc-body .muted { margin: 6px 0 0; }
.coc-pending { margin: 4px 0 0; padding-left: 18px; color: var(--problem); }
.coc-issue { margin-top: 6px; max-width: 640px; }
.coc-issue textarea { width: 100%; }
.coc-issue button.primary { margin-top: 10px; }

/* --- notifications ------------------------------------------------------- */

/* Unread count in the sidebar: a filled pill, so it reads at a glance. */
.note-badge:not(:empty) { background: #9a5f0f; color: #fff; border-radius: 100px;
                          padding: 1px 7px; font-size: 11px; }
.sidebar nav a.active .note-badge:not(:empty) { color: #fff; }
tr.unread td { background: #fbf8f1; }
.dot-new { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
           background: #9a5f0f; }

/* --- messages ------------------------------------------------------------ */

.msgs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 10px; }
.msg-client { background: var(--neutral-bg); align-self: flex-start; }
.msg-staff  { background: var(--progress-bg); align-self: flex-end; }
.msg-who { font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.msg-who .muted { font-weight: 400; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 100px;
    font-size: 12px;
    background: var(--surface);
}
.chip button { font-size: 14px; line-height: 1; text-decoration: none; }

/* --- branding ------------------------------------------------------------
 * The client company's name on the sign-in card; ours quietly at the foot of
 * the sidebar. Staff see the credit once a day, not on every card.
 */

.brand-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-tile {
    flex: 0 0 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 15px;
}

/* The card's own rule sets margin-bottom:24px on every <p>, which would push
   the subtitle away from the name it belongs to. */
.brand-header h1 { font-size: 18px; }
.brand-header p  { margin: 0; }

.powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 14px 20px 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* Masked rather than an <img>, so the mark takes the colour of the text it
   sits beside instead of being a blue dot next to grey words. */
.blutek-mark {
    display: inline-block;
    width: 14px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url(../img/blutek_mark_flat.svg) no-repeat center / contain;
    mask: url(../img/blutek_mark_flat.svg) no-repeat center / contain;
}

.signin-card .powered-by {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 760px) {
    /* The sidebar becomes a horizontal strip; a credit in it would eat width
       the nav needs. It is still on the sign-in card. */
    .sidebar .powered-by { display: none; }
}

/* --- my signature -------------------------------------------------------- */
.sig-pad-wrap { position: relative; max-width: 620px; border: 1px solid var(--border);
                border-radius: 8px; background: #fff; }
.sig-pad { display: block; width: 100%; height: auto; aspect-ratio: 900 / 260;
           touch-action: none; cursor: crosshair; }
.sig-line { position: absolute; left: 24px; right: 24px; bottom: 34px;
            border-top: 1px solid var(--border); font-size: 11px; color: var(--muted, #6b7280);
            padding-top: 4px; pointer-events: none; }
.sig-current { margin-bottom: 14px; }
.sig-current img { max-height: 70px; max-width: 320px; border-bottom: 1px solid var(--border); }

/* --- inspection reports -------------------------------------------------- */
.insp-reports { border-top: 1px solid var(--border); margin-top: 14px; }
.rep-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; flex-wrap: wrap; }
.rep-row + .rep-row { border-top: 1px dashed var(--border); }
.rep-row .grow { flex: 1; }
.sig-inline { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.sig-inline img { max-height: 34px; max-width: 160px; }
.sig-modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50;
             display: flex; align-items: center; justify-content: center; padding: 16px; }
.sig-modal-card { background: #fff; border-radius: 12px; padding: 22px; width: 100%;
                  max-width: 680px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }

/* --- version ------------------------------------------------------------- */
.build { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.signin-build { text-align: center; margin-top: 8px; }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 60;
              background: #14254a; color: #fff; border-radius: 10px; padding: 10px 14px;
              display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.25);
              font-size: 14px; max-width: calc(100% - 32px); }

/* Projects page */
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chips button .muted { margin-left: 4px; }
.filter-chips button.primary .muted { color: inherit; opacity: .8; }
#projects-search { width: 100%; }

/* Staff performance */
.page-head .filter-chips { margin-left: auto; }
.perf-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.perf-tile { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 16px; }
.perf-num { font-size: 26px; font-weight: 600; line-height: 1.1; margin-bottom: 4px; }
table.perf th.grp { text-align: left; border-bottom: 1px solid #e5e7eb; }
table.perf th .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }
table.perf td.slow { color: #b45309; font-weight: 600; }
table.perf td.late { color: #b91c1c; font-weight: 600; }
table.perf tr.open > td { background: #f3f6fa; }
table.perf tr.perf-detail > td { background: #f9fafb; padding: 6px 16px 14px; }
table.perf-items { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; }
.perf-note { font-size: 13px; margin-top: 4px; }
@media (max-width: 900px) { .card-body.tight { overflow-x: auto; } }

/* C.O.C. hold (1.9.5, DB 35) */
.coc-hold { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; margin-bottom: 12px;
            border: 1px dashed var(--border); border-radius: 8px; }
.coc-hold.on { display: block; border: 1px solid var(--problem); background: var(--problem-bg); }
.coc-hold .actions { display: flex; gap: 8px; margin-top: 8px; }
.coc-hold-form { flex-basis: 100%; margin-top: 8px; }
.coc-hold-form textarea { width: 100%; margin: 6px 0; }
.coc-hold-form .check { display: flex; gap: 8px; align-items: center; }
.coc-hold-history { margin-top: 10px; }
.coc-hold-history ul { margin: 6px 0 0; padding-left: 18px; }
