:root {
  color-scheme: light;
  --surface: #fff;
  --canvas: #f4f7f8;
  --ink: #12243a;
  --muted: #4b6174;
  --line: #d4dee3;
  --accent: #087566;
  --accent-dark: #06594f;
  --tint: #e6f6f0;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: var(--accent-dark); font-weight: 650; text-underline-offset: .2em; }
p { margin: 0 0 1rem; }
h1, h2, h3 { line-height: 1.18; margin: 0 0 .85rem; letter-spacing: -.025em; }
h1 { font-size: clamp(1.75rem, 3vw, 2.5rem); margin-bottom: .35rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; margin-top: .9rem; }
button, input, textarea, select { font: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 8px; background: var(--accent);
  color: white; font-weight: 650; text-decoration: none; padding: .62rem .9rem; cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-dark); }
button:disabled { cursor: default; opacity: .7; }
.secondary { color: var(--accent-dark); border-color: #9bbdb5; background: white; }
.secondary:hover { background: var(--tint); }
.link { background: none; color: var(--accent-dark); text-decoration: underline; padding: .2rem .36rem; }
.link:hover { background: var(--tint); }
.danger { color: #8b3336; }
:focus-visible { outline: 2px solid #168b9a; outline-offset: 2px; }

.topbar {
  min-height: 66px; padding: 0 max(18px, calc((100vw - 1540px) / 2));
  display: flex; gap: 1.2rem; align-items: center;
  color: var(--ink); background: white; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-size: 1.45rem; font-weight: 750; text-decoration: none; }
.mark { width: 23px; height: 23px; border-radius: 5px; background: linear-gradient(145deg, #13a392, #066879); }
.product { font-weight: 650; padding-left: 1.2rem; border-left: 1px solid var(--line); }
.local { margin-left: auto; font-size: .84rem; color: var(--muted); }
main { max-width: 1576px; padding: 28px 18px 48px; margin: auto; }
.pagehead { display: flex; gap: 1rem; align-items: end; justify-content: space-between; margin: .6rem 0 1.25rem; }
.pagehead p { color: var(--muted); margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; }
.back { display: inline-block; margin-bottom: .5rem; font-size: .92rem; }
.card { min-width: 0; padding: 1.15rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 7px #12243a07; }
.line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem .85rem; align-items: center; }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 99px; font-weight: 650; font-size: .82rem; text-transform: capitalize; background: #e9eef1; color: #455b6d; }
.badge[data-status="published"], .badge[data-status="reviewed"], .badge[data-status="submitted"] { background: var(--tint); color: var(--accent-dark); }
.badge[data-status="in progress"] { background: #e8f2fc; color: #24577e; }
.kicker { color: var(--accent-dark); font-weight: 650; font-size: .9rem; }
.case-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 1rem; }
.case { padding: 1.35rem; display: flex; flex-direction: column; }
.case h2 { font-size: 1.42rem; margin-top: .75rem; }
.case p { color: var(--muted); }
.case .actions { margin-top: auto; }
.table-card { margin-top: 1rem; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .62rem .68rem; border-bottom: 1px solid var(--line); text-align: left; }
th { background: #edf2f4; font-size: .9rem; }
.muted { color: var(--muted); font-size: .93rem; }
.build-grid, .review-grid { display: grid; grid-template-columns: 1.35fr 1fr; align-items: start; gap: 1rem; }
.start { max-width: 680px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .7rem; }
label { display: block; font-weight: 650; margin-bottom: .7rem; }
input:not([type="checkbox"]), textarea, select {
  display: block; width: 100%; min-width: 0; margin-top: .26rem; padding: .53rem .6rem;
  border: 1px solid #bac9d2; border-radius: 7px; background: white; color: var(--ink); font-weight: 400;
}
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); margin: 0; flex: none; }
textarea { min-height: 76px; resize: vertical; }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
fieldset[disabled] :is(input, textarea) { color: var(--ink); background: #f7fafb; opacity: 1; }
.choices { display: flex; flex-wrap: wrap; gap: .35rem .55rem; margin-bottom: .65rem; }
.choice { padding: .35rem .5rem; display: inline-flex; gap: .45rem; align-items: center; border: 1px solid var(--line); border-radius: 6px; margin: 0; font-size: .9rem; }
.upload { background: #eef9f6; border: 1px dashed #5eab9b; border-radius: 9px; padding: 1rem; color: var(--accent-dark); }
.upload > span { display: block; font-weight: 400; margin: .2rem 0 .55rem; }
.upload input { background: transparent; border: none; padding-left: 0; color: var(--ink); }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: .5rem; padding: .56rem 0; border-bottom: 1px solid var(--line); }
.file-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-kind { flex: none; border-radius: 5px; display: inline-block; padding: .13rem .35rem; background: #e8eff4; color: #31536c; font-size: .73rem; font-weight: 700; }
.brief { margin-bottom: 1rem; padding: .68rem 1rem; }
summary { font-weight: 650; cursor: pointer; }
.brief p { margin: .62rem 0 .35rem; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.work-grid { display: grid; grid-template-columns: minmax(160px, .53fr) minmax(220px, 1.03fr) minmax(390px, 1.32fr); align-items: start; gap: .8rem; }
.materials, .workspace { min-height: 525px; }
.materials { padding: .9rem; }
.file-select {
  justify-content: flex-start; gap: .5rem; text-align: left; width: 100%; color: var(--ink); background: white; border: 0;
  font-size: .88rem; padding: .65rem .35rem; overflow-wrap: anywhere;
}
.file-select + .file-select { margin-top: .25rem; }
.file-select:hover, .file-select.selected { background: var(--tint); }
.viewer { background: #eaf0f2; padding: .75rem; }
.viewer .line { padding: .15rem .15rem .65rem; overflow-wrap: anywhere; }
.viewer iframe, .document-image { width: 100%; display: block; border: 0; border-radius: 7px; background: white; }

.document-image { max-height: 100%; object-fit: contain; }
.sheet { min-height: 270px; background: white; border-radius: 7px; padding: 1.1rem; }
.sheet h3 { font-size: 1.1rem; margin-top: 0; }
dl { margin: .4rem 0 .8rem; }
dt { font-weight: 650; }
dd { margin: 0 0 .6rem; overflow-wrap: anywhere; }
.tabs { display: flex; flex-wrap: wrap; gap: .15rem .35rem; margin: 0 0 .85rem; border-bottom: 1px solid var(--line); }
.tabs button { background: white; color: var(--muted); padding: .43rem .4rem; border-radius: 0; font-size: .88rem; }
.tabs button[aria-pressed="true"] { color: var(--accent-dark); border-bottom: 3px solid var(--accent); }
.tabs button:hover { background: var(--tint); }
.journal { min-width: 355px; }
.journal td, .journal th { padding: .35rem .23rem; }
.journal th:first-child { width: 52%; }
.journal input, .journal select { margin: 0; padding: .38rem; font-size: .9rem; }
.journal-controls { margin: .45rem 0 .65rem; }
.journal-controls output { font-size: .83rem; font-variant-numeric: tabular-nums; }
.unbalanced { color: #8b3336; }
.evidence { margin: .9rem 0; }
.evidence .choices { margin: .55rem 0; }
.criterion { border-bottom: 1px solid var(--line); }
.criterion label { display: flex; gap: .75rem; align-items: center; justify-content: space-between; margin: 0; padding: .35rem 0; }
.criterion span { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
.criterion input { width: 70px; margin: 0; }
.score { display: flex; justify-content: space-between; padding: .65rem; background: var(--tint); color: var(--accent-dark); border-radius: 7px; margin: .9rem 0; font-weight: 650; }
.review-fields:empty { display: none; }
#messages { position: sticky; z-index: 1; top: 0; padding: .65rem 1rem; background: var(--tint); color: var(--accent-dark); text-align: center; font-weight: 650; }
#messages.error { background: #fcecee; color: #7c262a; }
@media (max-width: 950px) {
  .work-grid { grid-template-columns: minmax(160px, .7fr) minmax(250px, 1.3fr); }
  .workspace { grid-column: 1 / -1; }
  .materials, .viewer, .workspace { min-height: 0; }
}
@media (max-width: 650px) {
  .pagehead { align-items: start; flex-direction: column; }
  .work-grid, .build-grid, .review-grid { grid-template-columns: 1fr; }
  .topbar { gap: .6rem; }
  .product { padding-left: .6rem; font-size: .9rem; }
  .local { display: none; }
}
@media print {
  :root { background: white; }
  .back, .actions, #messages, .local, .file-list a { display: none !important; }
  .review-grid { display: block; }
  .card { border: none; box-shadow: none; padding: .5rem 0; }
}

.account-control { margin-left: auto; display: flex; align-items: center; gap: .65rem; font-size: .88rem; }
.account-control:empty { display: none; }
.sign-in-options { max-width: 850px; }
.sign-in-card { max-width: 540px; margin-top: 1rem; }
.sign-in-card > .badge { margin-bottom: .6rem; }
.account-list { display: grid; gap: .8rem; }
.account-list details form { margin-top: .65rem; }
@media print { .account-control { display: none; } }

.builder-head { margin-bottom: .8rem; }
.builder-nav { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 1rem; }
.builder-section { scroll-margin-top: 1rem; }
#case-tasks { grid-column: 1 / -1; }
.tool-category + .tool-category { margin-top: 1rem; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 265px), 1fr)); gap: .45rem; }
.tool-option {
  display: flex; gap: .5rem; align-items: flex-start; padding: .55rem .65rem; margin: 0;
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
}
.tool-option:has(:checked) { border-color: #7eb6aa; background: var(--tint); }
.tool-option input { margin-top: .18rem; }
.tool-option small { display: block; color: var(--muted); font-weight: 400; margin-top: .1rem; }
.source-editor { padding: .55rem .7rem .2rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .7rem; }
.source-editor legend { color: var(--muted); font-weight: 650; padding: 0 .35rem; }
.source-editor .line { justify-content: flex-end; }
#case-tasks > :is(div#chart-fields,div#custom-fields,details,label) { margin: 1rem 0 .4rem; }
.task-guidance { margin-top: .65rem; }
.task-instruction { padding: .6rem .75rem; border-left: 3px solid var(--accent); background: var(--tint); border-radius: 4px; }
.source-table caption { text-align: left; font-weight: 700; padding: .25rem 0 .55rem; }
.source-table td { overflow-wrap: anywhere; }
.work-wide { grid-template-columns: minmax(180px, .45fr) minmax(0, 1.55fr); }
.work-wide .workspace { grid-column: 1 / -1; }
.work-wide :is(.materials,.viewer,.workspace) { min-height: 0; }
.worksheet th { white-space: nowrap; }
.worksheet td { padding: .35rem .4rem; }
.worksheet input { min-width: 106px; margin: 0; }
.worksheet [type=date] { min-width: 140px; }
.worksheet select { min-width: 180px; margin: 0; }
.worksheet .number, .completed-sheet .number { text-align: right; font-variant-numeric: tabular-nums; }
.worksheet-actions { margin-top: .65rem; }
.worksheet-totals { font-variant-numeric: tabular-nums; font-size: .92rem; }
.completed-sheet { margin: .8rem 0; }
.completed-sheet td { overflow-wrap: anywhere; }
@media (max-width: 650px) {
  .builder-grid,.work-wide { grid-template-columns: 1fr; }
  .builder-nav { gap: .3rem; }
}
@media print {
  .completed-sheet .table-scroll { overflow: visible; }
  .completed-sheet th,.completed-sheet td { padding: .25rem .35rem; font-size: 9pt; }
}
.work-wide .materials nav { max-height: 325px; overflow: auto; }
.source-table thead th { position: sticky; top: 0; }
.workbook-launch { margin-bottom: .9rem; }

.adjustments-table { min-width: 485px; }
.adjustments-table th, .adjustments-table td { padding: .4rem; }
.adjustments-table input, .adjustments-table select { margin: 0; }
.adjustments-table select { min-width: 92px; }
.adjustments-table td:nth-child(3) input { min-width: 128px; }
.adjustments-table td:nth-child(4) { width: 19%; }
.adjustments-table td:nth-child(4) input { min-width: 80px; }
.reconciliation-adjustments > button { margin-top: .65rem; }
.reconciliation-totals {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .4rem .65rem; padding: .7rem; border: 1px solid var(--line);
  border-radius: .55rem; margin: .8rem 0; font-variant-numeric: tabular-nums;
}
.reconciliation-totals dt { font-size: .85rem; }
.reconciliation-totals dd { font-weight: 650; margin: .28rem 0 0; }
@media (max-width: 490px) { .reconciliation-totals { grid-template-columns: 1fr; } }

.viewer { position: relative; padding-bottom: 1.25rem; }
.viewer .viewer-toolbar { justify-content: flex-end; gap: .35rem; }
.viewer-toolbar button { padding: .34rem .55rem; font-size: .85rem; }
.viewer-content { height: var(--preview-height, 480px); overflow: auto; }
.viewer-content iframe { height: calc(100% - 2.2rem); min-height: 130px; }
.viewer-content .sheet { min-height: 0; }
.viewer-handle {
  position: absolute; z-index: 1; padding: 0; border: 0; border-radius: 4px;
  background: transparent; color: var(--muted); touch-action: none;
}
.viewer-handle:hover, .viewer-handle:focus-visible { background: var(--tint); color: var(--accent-dark); }
.viewer-handle span { display: block; background: currentColor; border-radius: 2px; }
.viewer-height-handle { inset: auto 20% 1px; height: 16px; cursor: ns-resize; }
.viewer-height-handle span { width: 32px; height: 3px; }
.viewer-width-handle { inset: 27% -8px 25% auto; width: 14px; cursor: ew-resize; }
.viewer-width-handle span { width: 3px; height: 32px; }
.viewer-dragging iframe { pointer-events: none; }
.work-wide .viewer-content { height: var(--preview-height, 350px); }
.work-wide .viewer-width-handle { right: auto; left: -8px; }
@media (min-width: 951px) {
  .work-grid:not(.work-wide).preview-width-custom {
    grid-template-columns: minmax(160px, .53fr) minmax(220px, min(var(--preview-width), calc(100% - 580px))) minmax(390px, 1.32fr);
  }
}
@media (min-width: 651px) {
  .work-wide { grid-template-columns: clamp(180px, var(--preview-source-width, 22.5%), 52%) minmax(0, 1fr); }
}
@media (min-width: 651px) and (max-width: 950px) {
  .work-grid:not(.work-wide) { grid-template-columns: clamp(160px, var(--preview-source-width, 35%), 52%) minmax(250px, 1fr); }
  .viewer-width-handle { right: auto; left: -8px; }
}
@media (max-width: 950px) {
  .work-grid:not(.work-wide) .viewer-content { height: var(--preview-height, 380px); }
}
@media (max-width: 650px) { .viewer-width-handle { display: none; } }
.viewer:is(:fullscreen, .preview-expanded) {
  display: flex; flex-direction: column; width: 100%; height: 100%;
  padding: .85rem; border-radius: 0;
}
.viewer.preview-expanded { position: fixed; inset: 0; z-index: 10; box-sizing: border-box; }
.viewer:is(:fullscreen, .preview-expanded) .viewer-content { flex: 1; min-height: 0; height: auto; }
.viewer:is(:fullscreen, .preview-expanded) .viewer-handle { display: none; }
.preview-scroll-lock { overflow: hidden; }
