:root {
  --cyan: #0e7490;
  --cyan-bright: #06b6d4;
  --ink: #1e293b;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --danger: #b91c1c;
  --ok: #15803d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 1.5rem;
}
.brand { font-size: 1.2rem; font-weight: 700; color: #fff; text-decoration: none; }
.brand span { color: var(--cyan-bright); }
.navwrap { display: flex; flex: 1; align-items: center; gap: 2rem; }
.navtoggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0.1rem 0.5rem; }
.topbar nav { display: flex; gap: 1.2rem; flex: 1; }
.topbar nav a { color: #cbd5e1; text-decoration: none; padding: 0.3rem 0; }
.topbar nav a:hover { color: #fff; }
.userbox { display: flex; align-items: center; gap: 0.8rem; color: #cbd5e1; }
.userbox small { color: var(--cyan-bright); }
.userlink { color: #cbd5e1; text-decoration: none; }
.userlink:hover { color: #fff; }

main { max-width: 1100px; margin: 1.5rem auto 3rem; padding: 0 1.5rem; }
footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1rem 0 2rem; }

h1 { font-size: 1.5rem; margin: 0.2rem 0 0.8rem; }
h1 small { color: var(--muted); font-weight: 400; font-size: 1.05rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }

.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
/* Compact inline filter sitting beside a page-head action button. */
.pagehead .headactions { display: flex; align-items: center; gap: 0.6rem; }
.pagehead .headactions .headfilter { margin: 0; }
.pagehead .headactions select { height: 2.1rem; }
/* Project workspace: left sidebar nav + content column. */
.projectlayout { display: flex; gap: 1.5rem; align-items: flex-start; }
.projectsidebar { flex: 0 0 13.5rem; position: sticky; top: 1rem; align-self: flex-start; }
.projectmain { flex: 1 1 auto; min-width: 0; }

/* Far-left, full-height project sidebar (Todoist-style): the workspace breaks out
   of the centred 1100px column so registers use the full browser width. Desktop
   only — the ≤720px rules keep the stacked mobile layout. */
@media (min-width: 721px) {
  body.layout-sidebar main { max-width: none; margin: 0; padding: 0; }
  body.layout-sidebar main > .msg { margin: 1rem 2rem 0; }
  body.layout-sidebar .projectlayout { gap: 0; align-items: stretch; }
  body.layout-sidebar .projectsidebar {
    flex: 0 0 15.5rem;
    box-sizing: border-box;
    position: sticky; top: 0;
    height: calc(100vh - 2.9rem);
    overflow-y: auto;
    background: var(--card);
    border-right: 1px solid var(--line);
    padding: 1.3rem 1rem;
    transition: flex-basis 0.22s ease, padding 0.22s ease, opacity 0.18s ease,
                border-right-width 0.22s ease;
  }
  /* Constrained, centred content column: fills up to a max width, then sits with
     EQUAL gutters on the left (after the sidebar) and the right. flex-grow is 0 so
     the auto margins absorb the free space symmetrically instead of stretching. */
  body.layout-sidebar .projectmain {
    flex: 0 1 1400px;
    box-sizing: border-box;
    min-width: 0;
    margin-inline: auto;
    padding: 1.6rem 2.2rem;
  }
}
.projecthead { margin-bottom: 0.8rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--line); }
.projecthead .crumbs { display: block; margin-bottom: 0.5rem; }
.projecthead h1 { margin: 0; font-size: 1.3rem; }
.projecthead .muted { font-size: 0.85rem; }
.projecthead .stageform { display: flex; gap: 0.3rem; margin-top: 0.5rem; }
.projecthead .stageform select { flex: 1 1 auto; min-width: 0; font-size: 0.8rem; padding: 0.2rem; }
.btn.xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }

/* Collapsible project sidebar — desktop only (mobile already stacks the nav). */
.sidebar-collapse, .sidebar-expand { display: none; }
@media (min-width: 721px) {
  body.layout-sidebar .projecthead { position: relative; }
  body.layout-sidebar .sidebar-collapse {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; top: -0.2rem; right: 0; width: 1.5rem; height: 1.5rem;
    border: 1px solid var(--line); background: #fff; border-radius: 6px;
    color: var(--muted); cursor: pointer; font-size: 1.05rem; line-height: 1;
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
  }
  body.layout-sidebar .sidebar-collapse:hover { color: var(--ink); background: var(--line); }
  /* Press feedback: the chevron dips left as it tucks the sidebar away. */
  body.layout-sidebar .sidebar-collapse:active { transform: translateX(-2px) scale(0.88); }
  /* Collapse by shrinking width/opacity (animatable) rather than display:none. */
  html.sidebar-collapsed body.layout-sidebar .projectsidebar {
    flex-basis: 0; padding-left: 0; padding-right: 0;
    opacity: 0; overflow: hidden; border-right-width: 0; pointer-events: none;
  }
  html.sidebar-collapsed body.layout-sidebar .subnav a,
  html.sidebar-collapsed body.layout-sidebar .navgroup { white-space: nowrap; }
  html.sidebar-collapsed body.layout-sidebar .sidebar-expand {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 3.4rem; left: 0.5rem; z-index: 30; width: 1.8rem; height: 1.8rem;
    border: 1px solid var(--line); background: #fff; border-radius: 6px;
    color: var(--muted); cursor: pointer; font-size: 1.15rem; line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
    animation: cyan-sidebar-pop 0.28s ease;
  }
  html.sidebar-collapsed body.layout-sidebar .sidebar-expand:hover { color: var(--ink); }
  html.sidebar-collapsed body.layout-sidebar .sidebar-expand:active { transform: translateX(2px) scale(0.88); }
}
@keyframes cyan-sidebar-pop {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  body.layout-sidebar .projectsidebar,
  body.layout-sidebar .sidebar-collapse,
  html.sidebar-collapsed body.layout-sidebar .sidebar-expand { transition: none; animation: none; }
}

/* Lifecycle stage badge */
.stagebadge {
  display: inline-block; margin-top: 0.5rem; padding: 0.1rem 0.5rem;
  border-radius: 999px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid transparent;
}
td .stagebadge { margin-top: 0; }
.stage-setup { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.stage-tender { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.stage-construction { background: #cffafe; color: #155e75; border-color: #67e8f9; }
.stage-closeout { background: #dcfce7; color: #166534; border-color: #86efac; }
.subnav { display: flex; flex-direction: column; gap: 0.1rem; }
.subnav a {
  padding: 0.4rem 0.7rem 0.4rem 1.1rem; color: var(--muted); text-decoration: none;
  font-weight: 600; font-size: 0.88rem; border-radius: 6px;
  border-left: 3px solid transparent; white-space: nowrap;
}
.subnav a:hover { color: var(--ink); background: var(--line); }
.subnav a.active { color: var(--cyan); background: var(--line); border-left-color: var(--cyan); }
.subnav .navgroup {
  margin: 0.95rem 0 0.25rem; padding: 0.6rem 0.7rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: #94a3b8; font-weight: 700;
}
.subnav .navgroup:first-child { margin-top: 0.25rem; padding-top: 0; border-top: none; }

@media (max-width: 720px) {
  .projectlayout { flex-direction: column; gap: 0.8rem; }
  .projectsidebar { position: static; flex-basis: auto; width: 100%; }
  .projecthead { padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
  .subnav { flex-direction: row; flex-wrap: wrap; gap: 0.25rem; }
  .subnav a { border-left: none; border: 1px solid var(--line); }
  .subnav a.active { border-color: var(--cyan); }
  .subnav .navgroup { display: none; }
}
.crumbs { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.3rem; }
.crumbs a { color: var(--cyan); text-decoration: none; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-style: italic; padding: 1.5rem 0; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin: 0.8rem 0; }
th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #f8fafc; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); }
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tr:last-child td:first-child { border-bottom-left-radius: 8px; }
tr:last-child td:last-child { border-bottom-right-radius: 8px; }
td { padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
td form { display: inline; }
.actions a { margin-right: 0.7rem; }

a { color: var(--cyan); }
.docid { font-family: Consolas, monospace; font-weight: 600; letter-spacing: 0.02em; }
/* Natural-language subject link (e.g. correspondence log) — normal text, not a doc ID. */
.subjectlink { font-weight: 600; text-decoration: none; }
.subjectlink:hover { text-decoration: underline; }
a.docid { text-decoration: none; }

.tag { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.tag.rev { background: #cffafe; color: var(--cyan); }
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.off { background: #fee2e2; color: var(--danger); }
.tag.plain { background: var(--line); color: var(--muted); }
.tag.warn { background: #fef3c7; color: #92400e; }
a.tag { text-decoration: none; }
.small { font-size: 0.78rem; }
tr.decisionrow td { background: #f8fafc; border-top: none; padding-top: 0.3rem; padding-bottom: 0.3rem; }
tr.decisionrow td:first-child { padding-left: 1.4rem; }

.docid.voided { text-decoration: line-through; color: var(--muted); }
tr.voidedrow td { background: #fef2f2; }
.voidbanner { border-left: 4px solid var(--danger); background: #fef2f2; }
.checkinline { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.checkinline input { width: auto; }
.btn.ghost.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost.danger:hover { background: #fef2f2; }
.btn.danger { background: var(--danger); }
.voidaction { margin-top: 0.8rem; }

.thread { margin: 1rem 0; display: flex; flex-direction: column; gap: 0.7rem; }
.bubble { border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.9rem; max-width: 78%; }
.bubble.from-admin { background: #ecfeff; border-color: #cffafe; align-self: flex-start; }
.bubble.from-contractor { background: var(--card); align-self: flex-end; }
.bubble-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.3rem; }
.bubble-body { white-space: normal; }
.rfc-attach { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; }
.rfc-attach-link { font-size: 0.82rem; }
table.kv { width: auto; margin: 0.6rem 0; }
table.kv th { background: none; text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 600; padding-right: 1.2rem; }

/* Register: fixed column layout, single-line rows, overflow ellipsizes (full text on hover). */
.register { table-layout: fixed; }
.register td, .register th { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.register th { position: relative; }
.colresizer { position: absolute; top: 0; right: -4px; width: 8px; height: 100%; cursor: col-resize; z-index: 5; }
.colresizer:hover { background: var(--cyan-bright); opacity: 0.4; }
.clip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.filerow { display: flex; justify-content: space-between; gap: 1rem; padding: 0.45rem 0.2rem; border-bottom: 1px solid var(--line); }
.filerow:last-child { border-bottom: none; }
.filerow-actions { display: inline-flex; align-items: center; gap: 0.7rem; white-space: nowrap; }

/* Super-admin destructive "Reset project" card. */
.dangerzone { border: 1px solid #fca5a5; background: #fef2f2; }
.dangerzone h3 { color: #b91c1c; }
.dangerzone .resetlabel { display: block; margin: 0.6rem 0; }
.dangerzone .resetlabel code { background: #fee2e2; padding: 0.05rem 0.35rem; border-radius: 4px; }
.dangerzone #reset-code { display: block; margin-top: 0.3rem; max-width: 16rem; }
.dangerzone .resetlabel input[type=text] { display: block; margin-top: 0.3rem; max-width: 22rem; width: 100%; }
.btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.danger:disabled { background: #fca5a5; border-color: #fca5a5; cursor: not-allowed; }

/* Visibility config: per-stage section grid + toggle row. */
.checkrow { display: flex; gap: 0.5rem; align-items: flex-start; line-height: 1.4; }
.checkrow input { margin-top: 0.15rem; }
.vis-grid td.vis-cell, .vis-grid th { text-align: center; }
.vis-grid td:first-child, .vis-grid th:first-child { text-align: left; }
.vis-grid input[type=checkbox] { width: 1.1rem; height: 1.1rem; }

/* Certification document groups: provided files + per-type upload combined. */
.doctypegroup { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.doctypegroup:last-of-type { border-bottom: none; }
.doctypegroup h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.uploadrow { margin-top: 0.5rem; }
.uploadrow input[type=file] { font-size: 0.9rem; max-width: 100%; }
.formactions { display: flex; gap: 0.6rem; margin-top: 1.1rem; flex-wrap: wrap; }

.iconbtn { position: relative; display: inline-block; background: none; border: none; cursor: pointer; color: var(--cyan); padding: 0.2rem 0.5rem 0.2rem 0.4rem; border-radius: 6px; line-height: 0; text-decoration: none; }
.actions .iconbtn { margin-right: 0.2rem; }
.iconbtn:hover { background: #ecfeff; color: var(--cyan-bright); }
.countbadge { position: absolute; top: -0.35rem; right: -0.25rem; background: var(--cyan); color: #fff; font-size: 0.62rem; font-weight: 700; line-height: 1; padding: 0.18rem 0.32rem; border-radius: 99px; min-width: 1.1em; text-align: center; }

.filesdlg { border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem 1.5rem; min-width: min(420px, 92vw); max-width: 92vw; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.25); }
.filesdlg::backdrop { background: rgba(15, 23, 42, 0.45); }
.filesdlg h2 { margin: 0 0 0.4rem; }
.filesdlg .filerow { text-align: left; }
.dlgfoot { margin-top: 1rem; text-align: right; }

/* Near-fullscreen dialog hosting the PDF viewer iframe (_viewer_modal.html). */
.viewerdlg { border: none; border-radius: 10px; padding: 0; width: 96vw; height: 94vh; max-width: 96vw; max-height: 94vh; overflow: hidden; box-shadow: 0 16px 48px rgba(15, 23, 42, 0.35); }
.viewerdlg::backdrop { background: rgba(15, 23, 42, 0.55); }
.viewerdlg iframe { display: block; width: 100%; height: 100%; border: 0; }

.btn {
  display: inline-block;
  background: var(--cyan);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--cyan-bright); }
.btn.ghost { background: transparent; color: var(--cyan); border: 1px solid var(--cyan); }
.btn.ghost:hover { background: #ecfeff; }
/* Filter toggle button: ghost when off, filled cyan when active. */
.btn.toggle.on { background: var(--cyan); color: #fff; }
.btn.toggle.on:hover { background: var(--cyan-bright); }
.linklike { background: none; border: none; color: var(--cyan); cursor: pointer; padding: 0; font-size: inherit; font-family: inherit; text-decoration: underline; }
.linklike.danger { color: var(--danger); }
.useractions { display: flex; align-items: center; gap: 0.85rem; }
.delactions { display: flex; align-items: center; gap: 0.85rem; margin-top: 0.7rem; }
.impactlist li { margin: 0.25rem 0; }
/* Modal dialog (e.g. edit a user's project access). */
.modal { border: none; border-radius: 10px; padding: 0; max-width: 30rem; width: calc(100% - 2rem); box-shadow: 0 14px 44px rgba(15, 23, 42, 0.28); }
.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.modal form { padding: 1.3rem 1.5rem; margin: 0; }
.modal h3 { margin: 0 0 0.2rem; }
.proj-checklist { display: flex; flex-direction: column; gap: 0.5rem; max-height: 50vh; overflow-y: auto; margin: 0.9rem 0 1.2rem; }
.proj-checklist .checkinline { white-space: normal; font-size: 0.9rem; color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem 1.5rem; margin: 0.8rem 0; }
.card.narrow { max-width: 480px; margin: 2rem auto; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 800px) { .cols { grid-template-columns: 1fr; } }

form p { margin: 0.7rem 0; }
form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
input[type=text], input[type=password], input[type=email], input[type=file], input[type=number], select, textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cyan-bright); border-color: transparent; }
.helptext { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 0.2rem; }
ul.errorlist { color: var(--danger); font-size: 0.85rem; margin: 0.2rem 0; padding-left: 1.1rem; }

.filters { display: flex; gap: 0.7rem; margin: 1rem 0; flex-wrap: wrap; align-items: center; }
.filter-inputs { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; width: 100%; }
.filters select, .filters input[type=text] { flex: 1 1 140px; min-width: 115px; width: auto; height: 2.1rem; }
.filter-inputs .btn, .filter-inputs .checkinline { flex: 0 0 auto; }
/* Register search typeahead. */
.search-wrap { position: relative; flex: 1 1 180px; min-width: 130px; display: flex; }
.search-wrap input[type=text] { width: 100%; }
.search-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40; margin-top: 3px;
  background: #fff; border: 1px solid var(--line); border-radius: 7px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); max-height: 19rem; overflow-y: auto;
}
.search-suggest a {
  display: flex; align-items: baseline; gap: 0.4rem; padding: 0.45rem 0.65rem;
  text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 0.85rem;
}
.search-suggest a:last-child { border-bottom: none; }
.search-suggest a:hover, .search-suggest a.active { background: var(--line); }
.search-suggest .s-id { font-weight: 600; color: var(--cyan); white-space: nowrap; }
.search-suggest .s-title { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.search-suggest .s-meta { color: var(--muted); font-size: 0.75rem; white-space: nowrap; flex: 0 0 auto; }
.warnbtn { background: #f59e0b; }
.warnbtn:hover { background: #d97706; }
.inline-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; }

.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; cursor: pointer; padding: 0.1rem 0.55rem; border-radius: 6px; font-weight: 700; color: var(--muted); user-select: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover, .menu[open] summary { background: var(--line); color: var(--ink); }
.menu-items { position: absolute; right: 0; top: 100%; z-index: 20; min-width: 130px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12); padding: 0.3rem; }
.menu-items a, .menu-items button { display: block; width: 100%; text-align: left; padding: 0.4rem 0.7rem; border: none; background: none; border-radius: 6px; font-size: 0.88rem; font-family: inherit; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-items a:hover, .menu-items button:hover { background: var(--bg); }
.menu-items button.danger, .menu-items a.danger { color: var(--danger); }
.menu-items form { display: block; }

/* Super-admin "View as" role switcher (topbar) + impersonation banner */
.viewas summary.userlink { color: #cbd5e1; font-weight: 600; }
.viewas summary.userlink:hover, .viewas[open] summary.userlink { background: #334155; color: #fff; }
.menu-items .menulabel { padding: 0.3rem 0.7rem 0.2rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.menu-items button.active { background: var(--bg); font-weight: 700; }
.menu-items button.active::after { content: " ✓"; color: var(--cyan); }
.menu-items button.return { color: var(--cyan); border-top: 1px solid var(--line); margin-top: 0.2rem; }
.viewas-banner { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap;
  background: #fde68a; color: #7c2d12; padding: 0.5rem 1rem; font-size: 0.9rem; border-bottom: 1px solid #f59e0b; }
.viewas-banner .linklike { color: #7c2d12; font-weight: 700; }

/* Tender clarifications (Q&A) */
.clarif { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.clarif:first-of-type { border-top: none; }
.clarif .qa { margin: 0.25rem 0; }
.clarif .qa.answer { padding-left: 0.8rem; border-left: 3px solid var(--cyan); }
.clarif h4, .card h4 { margin: 0.8rem 0 0.3rem; }
.navcount { display: inline-block; min-width: 1.15rem; padding: 0 0.35rem; background: var(--cyan); color: #fff; border-radius: 999px; font-size: 0.72rem; line-height: 1.15rem; text-align: center; vertical-align: middle; }

/* Sidebar-free project settings area */
.settingswrap { max-width: 70rem; }
.settingshead { margin: 0.2rem 0 1.2rem; }

/* Project configuration hub tiles */
.configgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.configtile { display: block; padding: 1rem 1.1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
.configtile:hover { border-color: var(--cyan); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08); }
.configtile h3 { margin: 0 0 0.3rem; color: var(--cyan); }
.configtile p { margin: 0; }

/* Site-note photo markup editor */
.anno-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin: 0.5rem 0 0.8rem; padding: 0.6rem 0.8rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.anno-tools, .anno-colors, .anno-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.anno-actions { margin-left: auto; }
.anno-tool { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0.7rem; font: inherit; font-size: 0.9rem; cursor: pointer; color: var(--ink); }
.anno-tool.active { background: var(--cyan); color: #fff; border-color: var(--cyan); }
.anno-color { width: 1.6rem; height: 1.6rem; border-radius: 99px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.anno-color.active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.anno-stage { background: #0f172a; border-radius: 8px; padding: 0.4rem; text-align: center; overflow: auto; }
.anno-canvas { max-width: 100%; height: auto; touch-action: none; cursor: crosshair; border-radius: 4px; }

/* Site-note photo gallery */
.markup-link { display: block; margin: 0 0.6rem 0.6rem; text-align: center; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin: 0.8rem 0; }
.photo { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #0f172a; }
.photo figcaption { padding: 0.5rem 0.7rem; font-size: 0.85rem; color: var(--ink); }
.caption-form { display: flex; gap: 0.4rem; padding: 0.5rem 0.6rem; align-items: center; }
.caption-form input { flex: 1; }
.caption-form .btn { flex: 0 0 auto; padding: 0.4rem 0.7rem; }

/* Email notification toggles */
.toggle-row { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.7rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle-row:last-of-type { border-bottom: none; }
.toggle-row input { width: auto; margin-top: 0.2rem; flex: 0 0 auto; }
.toggle-text { display: flex; flex-direction: column; gap: 0.15rem; }
.toggle-text small { display: block; }
.toggle-row.locked { cursor: default; }
.toggle-row.locked .toggle-text strong { color: var(--muted); }

.mailbody { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 0.9rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 0.8rem 1rem; margin: 0.4rem 0; }

/* Checkbox lists (transmittal document/member pickers) */
.checklist { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.7rem; background: #fff; }
.checklist ul { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: 0.2rem 0; }
.checklist label { display: inline; font-weight: 400; font-size: 0.9rem; }
.checklist input { width: auto; margin-right: 0.4rem; }

.msg { padding: 0.6rem 1rem; border-radius: 6px; margin: 0.6rem 0; font-size: 0.9rem; }
.msg.success { background: #dcfce7; color: var(--ok); }
.msg.error { background: #fee2e2; color: var(--danger); }
.msg.info, .msg.warning { background: #fef9c3; color: #854d0e; }

/* ---------------------------------------------------------------------------
   Mobile / responsive (phones & small tablets)
   --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  main { margin: 1rem auto 2rem; padding: 0 1rem; }

  /* Collapsible top nav: hamburger reveals nav + user box stacked full-width. */
  .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.6rem 1rem; }
  .brand { flex: 1; }
  .navtoggle { display: block; }
  .navwrap { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 0; }
  .topbar.open .navwrap { display: flex; }
  .topbar nav { flex: none; flex-direction: column; gap: 0; }
  .topbar nav a { padding: 0.7rem 0.2rem; border-bottom: 1px solid #334155; }
  .userbox { flex-direction: column; align-items: stretch; gap: 0.5rem; padding: 0.6rem 0.2rem 0.2rem; }
  .userbox .userlink { padding: 0.2rem 0; }

  /* Inputs at >=16px stop iOS from auto-zooming on focus. */
  input[type=text], input[type=password], input[type=email], input[type=file],
  input[type=number], select, textarea { font-size: 16px; }
  .filters select, .filters input[type=text] { flex: 1 1 100%; height: 2.4rem; }
  .card { padding: 1rem 1.1rem; }
  .pagehead .btn, .pagehead > div { width: 100%; }
  .pagehead > div { display: flex; flex-wrap: wrap; gap: 0.5rem; }
  .pagehead > div .btn { flex: 1 1 auto; text-align: center; }
  .bubble { max-width: 90%; }

  /* Card-reflow: each data-table row becomes a labelled stacked card.
     The .reflow class + per-cell data-label are added by responsive.js. */
  table.reflow { border: none; background: none; border-radius: 0; }
  table.reflow thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.reflow tbody, table.reflow tr, table.reflow td { display: block; width: 100%; }
  table.reflow tr {
    background: var(--card); border: 1px solid var(--line); border-radius: 8px;
    margin: 0 0 0.7rem; padding: 0.25rem 0.1rem;
  }
  table.reflow tr:hover td { background: none; }
  table.reflow td {
    border: none; border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.85rem;
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    white-space: normal; overflow: visible; text-overflow: clip; text-align: right;
  }
  table.reflow tr td:last-child { border-bottom: none; }
  table.reflow td::before {
    content: attr(data-label);
    flex: 0 0 38%; text-align: left;
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--muted); font-weight: 700;
  }
  table.reflow td[data-label=""]::before, table.reflow td:not([data-label])::before { content: none; }
  table.reflow .clip { max-width: none; white-space: normal; }
  /* Register: drop the fixed/nowrap layout so cards wrap naturally. */
  table.register.reflow { table-layout: auto; }
  table.register.reflow td, table.register.reflow th { white-space: normal; overflow: visible; text-overflow: clip; }
  .colresizer { display: none; }
  /* Indented sub-rows (decision history) read as a tinted nested card. */
  table.reflow tr.decisionrow { background: #f8fafc; margin-top: -0.4rem; }
  table.reflow tr.decisionrow td:first-child { padding-left: 0.85rem; }

  /* Filters/inline forms stack their controls. */
  .inline-form { width: 100%; }
  .inline-form select, .inline-form input { width: 100%; }
}

/* Document-ID builder */
.segment-list { list-style: none; padding: 0; margin: 0.6rem 0; max-width: 28rem; }
.segment-list .seg-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.35rem 0.6rem; margin: 0.25rem 0;
  border: 1px solid var(--border, #e2e8f0); border-radius: 6px; background: #fff;
}
.segment-list .seg-label { display: flex; align-items: center; gap: 0.5rem; }
.segment-list .seg-controls { display: flex; gap: 0.25rem; }
.segment-list .seg-controls button {
  border: 1px solid var(--border, #e2e8f0); background: #f8fafc; border-radius: 4px;
  cursor: pointer; line-height: 1; padding: 0.15rem 0.4rem; font-size: 0.7rem;
}
.id-preview-wrap { margin-top: 0.6rem; }
#id-preview { font-weight: 700; }

/* Custom-field management on project settings */
.customfields { margin-bottom: 1rem; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border, #e2e8f0); }
.chiplist { list-style: none; padding: 0; margin: 0.4rem 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chiplist li {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: #f1f5f9; border: 1px solid var(--border, #e2e8f0);
  border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.85rem;
}
.chiplist form.inline { display: inline; margin: 0; }
.chiplist .linklike { padding: 0; }

/* Tender pack: superseded-document prompt */
.outdated { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.outdated li { margin: 0.3rem 0; }
.outdated form.inline { display: inline; margin: 0 0 0 0.4rem; }

/* Bidder tender pack: hide superseded docs until toggled */
.filerow.sup { display: none; }
.show-sup-toggle:checked ~ .filerow.sup { display: flex; }
.show-sup-toggle { margin: 0.3rem 0.35rem 0.3rem 0; vertical-align: middle; }
label.showsup { font-size: 0.82rem; cursor: pointer; }

/* --- Drag-and-drop multi-file upload (js/multi-upload.js) ------------------ */
/* The native input is visually hidden but stays in the form so files submit. */
input[type="file"].mu-native {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mu-zone {
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0.25rem 0 0.75rem;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.mu-zone.mu-over {
  border-color: var(--cyan);
  background: rgba(14, 116, 144, 0.06);
}
.mu-prompt {
  color: var(--muted);
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 96px;
}
.mu-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.4rem; height: 1.4rem; flex: none;
  border-radius: 50%; background: var(--card);
  border: 1px solid var(--line); color: var(--cyan); font-weight: 700;
}
.mu-browse { padding: 0; font: inherit; }
.mu-list {
  list-style: none; margin: 0.6rem 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.mu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.4rem 0.6rem;
}
.mu-meta { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; flex: 1 1 auto; }
.mu-name { font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; min-width: 0; }
.mu-size { font-size: 0.78rem; color: var(--muted); flex: none; white-space: nowrap; }
.mu-remove {
  flex: none; border: none; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 0.9rem; line-height: 1;
  padding: 0.2rem 0.35rem; border-radius: 4px;
}
.mu-remove:hover { color: var(--danger); background: #fef2f2; }
.mu-zone .mu-err { margin: 0.5rem 0 0; }
