:root { font: 16px/1.55 var(--s4e-font, system-ui, sans-serif); color: #262626; background: #f5f4ee; --ink:#171717; --accent:#fff200; }
* { box-sizing: border-box; }
.print-only { display: none; }
body { margin: 0; display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
aside { padding: 1.5rem 1rem; background: var(--ink); color: white; }
@media screen {
  #sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    scrollbar-color: #a3a3a3 var(--ink);
  }
}
@media screen and (max-width: 700px) {
  #sidebar {
    position: static;
    height: auto;
    max-height: 35dvh;
  }
}
.brand { font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; gap: .55rem; margin: .4rem .35rem 1.8rem; }
.brand img { flex: none; }
.brand span { display: block; color: #d3d3d3; font-size: .72rem; font-weight: 500; }
a { text-decoration: none; color: inherit; }
nav { display: grid; gap: .15rem; }
nav a { border-radius: .45rem; padding: .44rem .65rem; color: #efefef; font-size: .9rem; }
nav a:hover, nav a[aria-current] { background: var(--accent); color: var(--ink); }
nav details a { display: block; margin-left: .45rem; }
nav summary { cursor: pointer; padding: .44rem .55rem; font-size: .9rem; }
main { padding: 1.5rem clamp(1rem, 4vw, 4rem); }
header, .hero, .actions { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
header label { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.hero { margin: 1.5rem 0; background: #eeece0; border-left: .35rem solid var(--accent); border-radius: 1rem; padding: clamp(1rem, 4vw, 2.6rem); }
.hero p { margin: .2rem 0; color: #454545; }
h1 { margin: .2rem 0; font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.05; letter-spacing: -.05em; overflow-wrap: anywhere; }
h2 { margin: 0 0 .8rem; }
#context { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
#metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .65rem; margin-bottom: 1rem; }
#metrics article, .panel { background: white; border: 1px solid #dedfd6; border-radius: .8rem; padding: 1rem; }
#metrics strong { display: block; font-size: 1.35rem; }
.table { overflow: auto; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 0 1rem; }
.filter input { width: min(22rem, 100%); }
.upcoming-assignment-filters label { display: inline-flex; align-items: center; gap: .35rem; }
.upcoming-assignment-filters input[type="checkbox"] { width: auto; }
.project-reporting-field { display: grid; gap: .25rem; margin: .65rem 0; max-width: 36rem; overflow-wrap: anywhere; }
.project-reporting-field select { min-width: 0; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .55rem; border-bottom: 1px solid #e5e6df; overflow-wrap: anywhere; }
th { font-size: .8rem; }
td a { text-decoration: underline; }
tr.highlighted { background: #fff9b8; }
tr.critical-activity { background: #fff4ed; color: #861c0d; }
button, input, select, textarea { font: inherit; border: 1px solid #818c83; border-radius: .4rem; padding: .4rem .6rem; max-width: 100%; }
button { background: var(--ink); color: white; cursor: pointer; }
.hero button { background: var(--accent); color: var(--ink); border-color: #7e7600; }
.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; }
.row-actions button { font-size: .8rem; }
.record-cell-label { display: none; }
@media screen and (max-width: 850px) {
  .record-table { min-width: 0; overflow: visible; }
  .record-table table, .record-table tbody { display: block; }
  .record-table thead {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    clip-path: inset(50%); overflow: hidden; white-space: nowrap;
  }
  .record-table tbody > tr {
    display: grid; grid-template-columns: minmax(0, 1fr);
    border: 1px solid #dedfd6; border-radius: .65rem;
    padding: .8rem; margin-top: .7rem; scroll-margin-top: 1rem;
  }
  .record-table td { display: block; min-width: 0; padding: .3rem 0; border: 0; }
  .record-table td:first-child { font-weight: 700; font-size: 1.1rem; }
  .record-table .record-cell-label {
    display: block; color: #525252; font-size: .75rem; font-weight: 700;
  }
  .record-table td:last-child {
    margin-top: .35rem; padding-top: .6rem; border-top: 1px solid #dedfd6;
  }
  .record-table td:last-child > .record-cell-label { margin-bottom: .35rem; }
  .record-table .row-actions {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: .45rem;
  }
  .record-table .row-actions > :is(button, a) {
    display: flex; align-items: center; justify-content: flex-start;
    width: 100%; min-height: 44px; padding: .45rem .65rem;
    text-align: left; overflow-wrap: anywhere; word-break: normal;
  }
}
dialog { width: min(33rem, calc(100% - 2rem)); border: 0; border-radius: .8rem; padding: 1.2rem; }
dialog::backdrop { background: #15262099; }
#fields label { display: grid; grid-template-columns: minmax(0, 1fr); gap: .25rem; margin: .65rem 0; }
#fields input[type="file"], #fields fieldset { min-width: 0; max-width: 100%; }
.project-setup-fields, .project-setup-team { margin: 1rem 0; }
.project-setup-team details { margin: .5rem 0; }
.project-setup-team summary { cursor: pointer; font-weight: 700; }
.setup-value { white-space: pre-wrap; overflow-wrap: anywhere; }
#fields .project-setup-team details label { display: flex; align-items: flex-start; gap: .45rem; overflow-wrap: anywhere; }
#fields .project-setup-team input[type="checkbox"] { flex: 0 0 auto; }
.inspection-check {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: .5rem;
}
.inspection-check button { margin-bottom: .65rem; }
.estimate-line { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .5rem; padding: .5rem; border-bottom: 1px solid #dedfd6; }
.estimate-line input { width: 100%; }
.estimate-line button { justify-self: start; }
#budgetLaunch label { display: grid; gap: .25rem; margin: .6rem 0; }
@media (max-width: 600px) {
  .inspection-check { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
textarea { resize: vertical; }
#photoDialog { width: min(56rem, calc(100% - 2rem)); }
#drawingComparison { width: min(90rem, calc(100% - 1rem)); }
.comparison-sheets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.comparison-sheets section { min-width: 0; border: 1px solid #dedfd6; border-radius: .5rem; padding: .65rem; }
.comparison-sheets h3, .comparison-sheets p { margin: .3rem 0; }
.comparison-sheets a { text-decoration: underline; }
.comparison-sheets iframe, .comparison-sheets img { display: block; width: 100%; margin-top: .5rem; border: 0; }
.comparison-sheets iframe { height: 55dvh; }
.comparison-sheets img { height: 55dvh; object-fit: contain; background: #f5f4ee; }
.table td small { display: block; }
.finance-grid th, .finance-grid td { min-width: 6rem; }
.finance-grid th:first-child, .finance-grid td:first-child { min-width: 10rem; }
.finance-grid td:not(:first-child):not(:last-child) { white-space: nowrap; }
.diary-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .5rem; }
.diary-groups section { min-width: 0; }
.diary-groups a { text-decoration: underline; overflow-wrap: anywhere; }
#submittalRows { width: 100%; display: block; }
#submittalPreview { max-height: 15rem; overflow: auto; overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .comparison-sheets { grid-template-columns: minmax(0, 1fr); }
  .comparison-sheets img, .comparison-sheets iframe { height: 42dvh; }
}
#photoTitle { overflow-wrap: anywhere; }
#photoPreview { display: block; width: auto; max-width: 100%; max-height: 55dvh; height: auto; }
.photo-stage { display: flex; justify-content: center; margin: .7rem 0; }
#photoSurface { position: relative; width: fit-content; max-width: 100%; }
#photoOverlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#photoOverlay.drawing { pointer-events: auto; touch-action: none; cursor: crosshair; }
.photo-tools { display: flex; align-items: end; gap: .5rem; flex-wrap: wrap; }
.photo-tools label { display: grid; gap: .15rem; min-width: 0; }
#assignmentDialog { width: min(45rem, calc(100% - 1.5rem)); }
#assignmentInbox article { border-top: 1px solid #dedfd6; padding: .7rem 0; overflow-wrap: anywhere; }
.assignment-popup { position: fixed; inset: auto 1rem 1rem auto; z-index: 10; width: min(24rem, calc(100vw - 2rem));
  background: white; color: #171717; border: 2px solid #675e00; border-radius: .7rem; padding: 1rem; overflow-wrap: anywhere; }
@media print { .assignment-popup { display: none !important; } }
#photoMarkupInfo:empty { display: none; }
@media print {
  #photoTools { display: none !important; }
}
#photoNotice:empty { display: none; }
.download-button { background: var(--ink); color: white; border-radius: .4rem; padding: .4rem .6rem; }
.connection-notice { grid-column: 1 / -1; margin: 0; padding: .55rem 1rem; background: #fff9b8; color: #222821; }
@media (display-mode: standalone) {
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}
#jobsDialog { width: min(64rem, calc(100% - 2rem)); }
.job-filters { display: flex; flex-wrap: wrap; gap: .65rem; }
.job-filters label { display: grid; gap: .25rem; }
#jobCatalog details { border-top: 1px solid #dedfd6; padding: .65rem 0; }
#jobCatalog summary { cursor: pointer; font-weight: 700; }
.job-versions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; }
.job-versions p { margin: .55rem 0; }

@media print {
  @page { margin: 13mm; }
  :root { background: white; color: #171717; font-size: 10pt; }
  body { display: block; min-height: 0; }
  body > :is(aside, dialog), #connectionNotice, #workspace > header, .account-bar,
  .filter, #notice, .print-exclude, .row-actions, button, dialog form, dialog .job-filters {
    display: none !important;
  }
  body[data-print-mode] #printHeader {
    display: grid;
    grid-template-columns: 14mm minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 4mm;
    align-items: start;
    border-bottom: 2pt solid #675e00;
    padding-bottom: 3mm;
    margin-bottom: 5mm;
    break-inside: avoid;
    overflow-wrap: anywhere;
  }
  #printHeader img { width: 14mm; height: 14mm; object-fit: contain; }
  #printHeader strong { font-size: 12pt; }
  #workspace { padding: 0; }
  #workspace .hero, #workspace .panel {
    margin: 0 0 4mm;
    padding: 0;
    border: 0;
    background: white;
  }
  #workspace .hero h1, #printRecord h1 { font-size: 17pt; letter-spacing: 0; }
  #metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #metrics article { padding: 2mm; break-inside: avoid; }
  #metrics strong { font-size: 11pt; }
  .table { overflow: visible; }
  .table th, .table td { min-width: 0; padding: 1mm; font-size: 8pt; white-space: normal !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  body[data-print-mode="record"] #workspace, body[data-print-mode="dialog"] #workspace {
    display: none !important;
  }
  body[data-print-mode="record"] #printRecord { display: block; }
  #printRecord dt { font-weight: 700; break-after: avoid; }
  #printRecord dd { margin: 0 0 2mm; white-space: pre-wrap; overflow-wrap: anywhere; }
  body[data-print-mode="dialog"] dialog.print-dialog {
    display: block !important;
    position: static;
    width: auto;
    max-height: none;
    overflow: visible;
    margin: 0;
    padding: 0;
  }
  dialog::backdrop { background: transparent; }
}
#formError { color: #9a1420; }
.cad-actions { margin-top: .4rem; }
#cadVersions details { border-top: 1px solid #dedfd6; padding: .6rem 0; }
#cadVersions summary { cursor: pointer; font-weight: 600; }
#cadVersions a { text-decoration: underline; }
#cadVersions textarea { display: block; width: 100%; margin: .25rem 0; }
.cad-notes p { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .2rem; }
#chatDialog { width: min(62rem, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); }
.chat-header, .chat-compose { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.chat-header h2, #chatThread h3 { margin: 0; }
.chat-disclosure, #chatMembers { font-size: .85rem; color: #545454; margin: .4rem 0; overflow-wrap: anywhere; }
.chat-layout { display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: .8rem; }
#chatList { align-content: start; max-height: 53dvh; overflow: auto; }
#chatList button { width: 100%; text-align: left; overflow-wrap: anywhere; }
#chatList button[aria-current] { background: var(--accent); color: var(--ink); }
#chatMessages { display: flex; flex-direction: column; align-items: stretch; gap: .5rem; height: min(49dvh, 30rem); overflow-y: auto; padding: .6rem; background: #f5f4ee; border-radius: .5rem; }
.chat-message { align-self: flex-start; max-width: 90%; padding: .5rem .65rem; background: white; border: 1px solid #ddd; border-radius: .5rem; overflow-wrap: anywhere; }
.chat-message.mine { align-self: flex-end; background: #fff9b8; }
.chat-message p { margin: .25rem 0; white-space: pre-wrap; }
.chat-message blockquote { margin: .3rem 0; padding-left: .5rem; border-left: 2px solid #777; font-size: .85rem; }
.chat-message button { padding: .1rem .35rem; margin-left: .4rem; font-size: .75rem; }
.chat-compose { flex-wrap: nowrap; }
.chat-compose textarea { flex: 1; min-width: 0; }
#chatReply { display: flex; gap: .5rem; align-items: center; font-size: .8rem; overflow-wrap: anywhere; }
#chatCreate label { display: block; margin: .4rem 0; }
#chatContacts { max-height: 40dvh; overflow: auto; }
@media (max-width: 650px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  #chatList { display: flex; overflow: auto; max-height: 5rem; }
  #chatList button { width: auto; flex: none; max-width: 12rem; }
  #chatMessages { height: 38dvh; }
}
[hidden] { display: none !important; }
.login-panel { grid-column: 1 / -1; width: min(28rem, calc(100% - 2rem)); align-self: start; margin: 8vh auto; }
.login-panel h1 { font-size: 2rem; margin-bottom: 1rem; }
.login-panel .remember-device { display: flex; align-items: baseline; gap: .4rem; }
.login-panel label, #userForm > label, #passwordForm > label { display: grid; gap: .25rem; margin: .5rem 0; }
.module-directory { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .8rem; }
.module-directory h3 { margin: .2rem 0; }
.module-directory ul { list-style: none; padding: 0; margin: .2rem 0; }
.module-directory a { display: inline-block; padding: .2rem 0; text-decoration: underline; }
.project-directory { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.project-directory article { border: 1px solid #dedfd6; border-radius: .5rem; padding: .8rem; overflow-wrap: anywhere; }
.project-directory h3, .project-directory p { margin: 0 0 .55rem; }
#userForm fieldset label { display: block; }
.account-bar { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
#userList { display: flex; gap: .4rem; flex-wrap: wrap; max-height: 10rem; overflow: auto; margin-top: .5rem; }
#userScope label { display: block; }
.timeline { list-style: none; padding: 0; }
.timeline li { margin-bottom: .7rem; }
.timeline-track { background: #eeece0; border-radius: .25rem; overflow: hidden; }
.timeline-track div { background: var(--accent); min-height: .7rem; }
.baseline-track div { background: #718078; }
.timeline small, .timeline strong { display: block; }
.timeline-track { margin-bottom: .3rem; }
.schedule-controls { display: flex; flex-wrap: wrap; gap: .55rem 1rem; align-items: center; margin-bottom: .75rem; }
@media (max-width: 700px) {
  body { grid-template-columns: minmax(0, 1fr); }
  aside { padding: .65rem; }
  .brand { margin: .2rem .3rem .7rem; }
  nav { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); align-items: start; }
}
