.estimate-main { max-width: 1400px; }
.estimate-intro { display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; margin-bottom:1rem; }
.estimate-intro h2, .estimate-form h2, .estimate-preview-panel h2 { margin:.15rem 0 .35rem; color:var(--green); }
.estimate-intro p:not(.portal-card-kicker) { max-width:60rem; margin:0; color:var(--muted); line-height:1.5; }
.estimate-status-chip { padding:.4rem .7rem; color:#0d4c16; background:#e4f2e0; border:1px solid #a9caa1; border-radius:999px; font-weight:800; white-space:nowrap; }
.estimate-layout { display:grid; grid-template-columns:minmax(320px, .95fr) minmax(440px, 1.05fr); gap:1rem; align-items:start; }
.estimate-form, .estimate-preview-panel { display:grid; gap:1rem; }
.estimate-history-panel { display:grid; gap:1rem; min-width:0; margin-top:1rem; }
.estimate-history-layout { display:grid; grid-template-columns:minmax(240px,.7fr) minmax(420px,1.3fr); gap:1rem; align-items:start; min-width:0; }
.estimate-history-layout > *, .estimate-history-list, .estimate-history-preview { min-width:0; }
.submission-history-list-panel { display:grid; gap:.6rem; min-width:0; }
.submission-list-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.55rem; min-width:0; padding:.1rem 0 .55rem; border-bottom:1px solid var(--line); }
.submission-list-controls .portal-history-filter { display:grid; grid-template-columns:1fr; gap:.25rem; align-items:stretch; min-width:0; color:var(--green); font-size:.78rem; letter-spacing:.02em; }
.submission-list-controls .portal-history-filter select { width:100%; min-width:0; }
.estimate-history-list { display:grid; gap:.6rem; max-height:650px; overflow:auto; }
.estimate-history-item { display:grid; gap:.2rem; width:100%; padding:.8rem 1rem; color:var(--ink); background:#f6f9f3; border:1px solid var(--line); border-radius:.7rem; text-align:left; cursor:pointer; }
.estimate-history-item:hover, .estimate-history-item:focus-visible { border-color:var(--green); box-shadow:0 0 0 3px rgba(18,61,29,.12); outline:0; }
.estimate-history-item[aria-current="true"] { border-color:#cda72e; background:#fffbed; }
.estimate-history-item strong { color:var(--green); }
.estimate-history-item small { color:var(--muted); }
.estimate-history-preview { min-height:520px; }
.estimate-form-heading, .estimate-preview-toolbar { display:flex; justify-content:space-between; gap:1rem; align-items:end; }
.estimate-form-heading h2, .estimate-preview-toolbar h2 { margin:0; }
.estimate-lines { display:grid; gap:.65rem; }
.estimate-line { display:grid; grid-template-columns:minmax(0,1fr) 82px 120px 120px auto; gap:.5rem; align-items:end; padding:.7rem; background:#f6f9f3; border:1px solid var(--line); border-radius:.75rem; }
.estimate-line label { display:grid; gap:.25rem; color:var(--muted); font-size:.82rem; font-weight:800; }
.estimate-line input { width:100%; }
.estimate-line-total { padding-bottom:.7rem; color:var(--green); font-weight:900; text-align:right; }
.estimate-line-remove { min-height:40px; padding:.45rem .6rem; color:#8b2525; background:#fff; border:1px solid #d9aaaa; border-radius:.5rem; }
.estimate-actions { display:flex; flex-wrap:wrap; gap:.65rem; padding-top:.25rem; border-top:1px solid var(--line); }
.estimate-preview-panel { position:sticky; top:1rem; }
.estimate-paper { min-height:760px; padding:2.4rem; color:#1e293b; background:#fff; border:1px solid #d9dfd4; box-shadow:0 12px 30px rgba(0,0,0,.1); font-family:Arial,sans-serif; }
.estimate-paper-header { display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; padding-bottom:1.5rem; border-bottom:2px solid #cda72e; }
.estimate-paper-logo { display:block; width:250px; max-width:48%; height:auto; object-fit:contain; object-position:left center; }
.estimate-paper-company { color:#17241b; font-size:.82rem; font-weight:800; text-align:right; }
.estimate-paper-company p { margin:.15rem 0; }
.estimate-paper-title { margin:2.2rem 0 1.6rem; color:#17241b; font-size:1.55rem; letter-spacing:.08em; text-align:center; text-transform:uppercase; }
.estimate-paper-meta { display:grid; grid-template-columns:1fr auto; gap:1rem; margin-bottom:1.6rem; font-size:.92rem; }
.estimate-paper-meta p { margin:.2rem 0; }
.estimate-paper-body { min-height:300px; font-size:.95rem; line-height:1.55; }
.estimate-paper-table { width:100%; margin:1.2rem 0; border-collapse:collapse; font-size:.9rem; }
.estimate-paper-table th, .estimate-paper-table td { padding:.55rem .35rem; border-bottom:1px solid #d9dfd4; text-align:left; }
.estimate-paper-table th:not(:first-child), .estimate-paper-table td:not(:first-child) { text-align:right; }
.estimate-paper-total { margin-left:auto; width:min(280px,100%); font-size:.95rem; }
.estimate-paper-total p { display:flex; justify-content:space-between; gap:1rem; margin:.35rem 0; }
.estimate-paper-total .grand-total { padding-top:.55rem; color:#123d1d; border-top:2px solid #cda72e; font-size:1.1rem; font-weight:900; }
.estimate-paper-terms { margin-top:2rem; white-space:pre-line; font-size:.88rem; line-height:1.5; }
@media (max-width:900px) { .estimate-layout, .estimate-history-layout { grid-template-columns:1fr; } .estimate-preview-panel { position:static; } }
@media (max-width:700px) { .estimate-intro, .estimate-form-heading, .estimate-preview-toolbar { align-items:flex-start; flex-direction:column; } .estimate-line { grid-template-columns:1fr 1fr; } .estimate-line label:first-child { grid-column:1/-1; } .estimate-line-total { text-align:left; } .estimate-paper { min-height:0; padding:1.1rem; } .estimate-paper-header { flex-direction:column; } .estimate-paper-logo { max-width:80%; } .estimate-history-layout { gap:.75rem; } .estimate-history-list { max-height:none; } .submission-list-controls { grid-template-columns:1fr; } }
@media print { body { background:#fff; } .app-header, .estimate-intro, .estimate-form, .estimate-preview-toolbar { display:none !important; } .estimate-main, .estimate-layout, .estimate-preview-panel { display:block; max-width:none; margin:0; padding:0; } .estimate-paper { min-height:0; border:0; box-shadow:none; } }

/* Submitted documents uses a dense record column so the document list stays
   scannable while its selected preview keeps the existing paper layout. */
.submissions-record-list {
  max-height: 560px;
  overflow-x: hidden;
  overflow-y: auto;
  gap: .4rem;
  padding: .1rem;
  scrollbar-width: thin;
}

/* Pay-month workspace mobile-first pass. The list is a compact two-line
   record row; the preview keeps its spreadsheet width inside one scroll
   region instead of reflowing cells into overlapping pseudo-labels. */
.pay-month-workspace { overflow: hidden; }
.pay-month-layout { grid-template-columns: minmax(0, 1fr); }
.pay-month-list-panel, .pay-month-preview, .pay-month-sheet-preview { min-width: 0; }
.pay-month-list { max-height: none; overflow: visible; }
.pay-month-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: .2rem .65rem;
  align-items: start;
  min-width: 0;
  padding: .7rem .75rem;
}
.pay-month-list-item-heading { display: contents; }
.pay-month-list-item-heading strong {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.pay-month-list-item-heading .portal-status {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  white-space: nowrap;
}
.pay-month-list-item-month {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.pay-month-list-item small {
  grid-column: 1 / -1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.pay-month-preview { overflow: hidden; }
.pay-month-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
.pay-month-edit-table { min-width: 54rem; }
.pay-month-edit-actions { align-items: flex-start; }
.pay-month-download { white-space: normal; }
.pay-month-download-status { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .pay-month-layout { grid-template-columns: minmax(250px, .75fr) minmax(0, 1.65fr); }
  .pay-month-preview { position: sticky; top: 1rem; }
}

@media (max-width: 700px) {
  .pay-month-layout { gap: .75rem; }
  .pay-month-list { max-height: 360px; overflow-y: auto; padding-right: .1rem; }
  .pay-month-preview { padding: .9rem; }
  .pay-month-edit-table { display: table; min-width: 54rem; }
  .pay-month-edit-table thead { display: table-header-group; }
  .pay-month-edit-table tbody { display: table-row-group; }
  .pay-month-edit-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .pay-month-edit-table th, .pay-month-edit-table td { display: table-cell; width: auto; padding: .5rem .45rem; border-bottom: 1px solid #e0e5dd; vertical-align: middle; }
  .pay-month-edit-table td::before { display: none; }
  .pay-month-edit-actions { display: grid; grid-template-columns: 1fr; gap: .55rem; }
  .pay-month-edit-actions .small-text { min-width: 0; }
}
.submission-record-header,
.submission-record-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(7rem, .85fr) minmax(9rem, 1fr) minmax(6.5rem, .75fr);
  gap: .65rem;
  align-items: center;
  min-width: 0;
}
.submission-record-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: .35rem .75rem;
  color: var(--muted);
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.submission-record-row {
  padding: .55rem .75rem;
  border-radius: .6rem;
}
.submission-record-cell {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}
.submission-record-cell strong,
.submission-record-cell small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}
.submission-record-cell strong { color: var(--green); font-size: .94rem; line-height: 1.2; }
.submission-record-cell small { margin-top: .14rem; color: var(--muted); font-size: .7rem; line-height: 1.2; }
.submission-record-type,
.submission-record-date,
.submission-record-status { color: var(--ink); font-size: .78rem; line-height: 1.25; }
.submission-record-status { font-weight: 800; }
.submission-record-row[aria-current="true"] { box-shadow: 0 0 0 2px #cda72e inset; }

@media (max-width: 700px) {
  .submissions-record-list { max-height: 370px; }
  .submission-record-header { display: none; }
  .submission-record-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .38rem .65rem;
    padding: .6rem .7rem;
  }
  .submission-record-user { grid-column: 1 / -1; }
  .submission-record-type::before,
  .submission-record-date::before,
  .submission-record-status::before {
    display: block;
    margin-bottom: .12rem;
    color: var(--muted);
    font-size: .64rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .submission-record-type::before { content: "Type"; }
  .submission-record-date::before { content: "Date"; }
  .submission-record-status::before { content: "Status"; }
  .submission-record-type,
  .submission-record-date,
  .submission-record-status { font-size: .76rem; }
  .submission-record-status { grid-column: 1 / -1; }
}

/* Pay-month workspace: keep navigation compact and give the selected sheet
   the space it needs on wide displays without creating a horizontal page
   overflow on phones. */
.submission-type-tabs {
  display: flex;
  gap: .45rem;
  max-width: 100%;
  overflow-x: auto;
  padding: .15rem .05rem .45rem;
  scrollbar-width: thin;
}
.submission-type-tabs button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: .5rem .75rem;
  color: var(--green);
  background: #f5f8f1;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 850;
  white-space: nowrap;
}
.submission-type-tabs button:hover,
.submission-type-tabs button:focus-visible { border-color: var(--green); outline: 0; box-shadow: 0 0 0 3px rgba(18,61,29,.12); }
.submission-type-tabs button[aria-selected="true"] { color: #fff; background: var(--green); border-color: var(--green); }
.pay-month-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .75rem;
  padding: .2rem 0 .75rem;
  border-bottom: 1px solid var(--line);
}
.pay-month-filters .portal-history-filter { display: grid; gap: .25rem; color: var(--green); font-size: .78rem; font-weight: 850; }
.pay-month-filters select { width: 100%; min-width: 0; }
.pay-month-layout {
  display: grid;
  grid-template-columns: minmax(260px, .75fr) minmax(0, 1.65fr);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}
.pay-month-list-panel { display: grid; gap: .55rem; min-width: 0; }
.pay-month-list-heading { display: flex; justify-content: space-between; gap: .75rem; align-items: end; padding: .1rem .1rem .2rem; }
.pay-month-list-heading h3 { margin: .1rem 0 0; color: var(--green); }
.pay-month-list-item { gap: .35rem; padding: .75rem .85rem; }
.pay-month-list-item-heading { display: flex; justify-content: space-between; gap: .5rem; align-items: start; }
.pay-month-list-item-heading strong { min-width: 0; overflow-wrap: anywhere; }
.pay-month-list-item-month { color: var(--ink); font-size: .8rem; font-weight: 800; line-height: 1.3; }
.pay-month-list-item small { line-height: 1.35; }
.pay-month-preview { position: sticky; top: 1rem; min-width: 0; min-height: 0; }
.pay-month-preview .pay-month-sheet-preview { min-width: 0; }
.pay-month-edit-note { margin: 0 0 1rem; padding: .65rem .75rem; color: #694d00; background: #fff8dc; border: 1px solid #d8be63; border-radius: .55rem; font-size: .85rem; }
.pay-month-table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid #d9dfd4; border-radius: .6rem; }
.pay-month-edit-table { width: 100%; min-width: 680px; margin: 0; border-collapse: collapse; font-size: .82rem; }
.pay-month-edit-table th { color: var(--muted); background: #f4f7f0; font-size: .72rem; letter-spacing: .03em; text-transform: uppercase; }
.pay-month-edit-table th, .pay-month-edit-table td { padding: .55rem .45rem; border-bottom: 1px solid #e0e5dd; vertical-align: middle; text-align: left; }
.pay-month-edit-table tbody tr:last-child td { border-bottom: 0; }
.pay-month-edit-table tbody tr.is-read-only { opacity: .72; }
.pay-month-edit-table input, .pay-month-edit-table select { width: 100%; min-width: 0; padding: .45rem .5rem; font-size: .82rem; }
.pay-month-edit-table input[type="date"] { min-width: 9.3rem; }
.pay-month-edit-table input[type="time"] { min-width: 6.4rem; }
.pay-month-edit-table .pay-month-row-hours { display: inline-block; min-width: 3.5rem; color: var(--green); font-weight: 850; white-space: nowrap; }
.pay-month-sheet-total { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-top: .65rem; padding: .75rem .9rem; border: 1px solid #b8cdb3; border-radius: .65rem; background: #edf5e9; color: var(--green); font-weight: 800; }
.pay-month-sheet-total strong { font-size: 1.05rem; white-space: nowrap; }
.pay-month-edit-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; padding-top: .85rem; }
.pay-month-edit-actions .small-text { flex: 1 1 15rem; min-width: 12rem; }

/* The left pane is intentionally narrow. Record-type tabs use a compact
   two-column card there so names never collapse into one letter per line. */
.pay-month-list-panel .submission-record-header { display: none; }
.pay-month-list-panel .submission-record-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .38rem .65rem;
  padding: .6rem .7rem;
}
.pay-month-list-panel .submission-record-user { grid-column: 1 / -1; }
.pay-month-list-panel .submission-record-type::before,
.pay-month-list-panel .submission-record-date::before,
.pay-month-list-panel .submission-record-status::before {
  display: block;
  margin-bottom: .12rem;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.pay-month-list-panel .submission-record-type::before { content: "Type"; }
.pay-month-list-panel .submission-record-date::before { content: "Date"; }
.pay-month-list-panel .submission-record-status::before { content: "Status"; grid-column: 1 / -1; }
.pay-month-list-panel .submission-record-status { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .pay-month-preview { position: static; }
  .pay-month-layout { grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); }
}
@media (max-width: 700px) {
  .pay-month-filters { grid-template-columns: 1fr; }
  .pay-month-layout { grid-template-columns: 1fr; gap: .75rem; }
  .pay-month-list { max-height: 330px; }
  .pay-month-preview { padding: 1rem; }
  .pay-month-edit-table { min-width: 0; border: 0; }
  .pay-month-table-scroll { border: 0; overflow: visible; }
  .pay-month-edit-table thead { display: none; }
  .pay-month-edit-table, .pay-month-edit-table tbody, .pay-month-edit-table tr, .pay-month-edit-table td { display: block; width: 100%; }
  .pay-month-edit-table tbody { display: grid; gap: .65rem; }
  .pay-month-edit-table tr { padding: .65rem; border: 1px solid var(--line); border-radius: .65rem; background: #fbfdf9; }
  .pay-month-edit-table td { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: .5rem; align-items: center; padding: .28rem 0; border: 0; }
  .pay-month-edit-table td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 900; letter-spacing: .03em; text-transform: uppercase; }
  .pay-month-edit-table input[type="date"], .pay-month-edit-table input[type="time"] { min-width: 0; }
}

/* Final mobile-first overrides for the submitted pay-month workspace. */
.pay-month-workspace { overflow: hidden; }
.pay-month-layout { grid-template-columns: minmax(0, 1fr); }
.pay-month-list-panel, .pay-month-preview, .pay-month-sheet-preview { min-width: 0; }
.pay-month-list { max-height: none; overflow: visible; }
.pay-month-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto auto;
  gap: .2rem .65rem;
  align-items: start;
  min-width: 0;
  padding: .7rem .75rem;
}
.pay-month-list-item-heading { display: contents; }
.pay-month-list-item-heading strong { grid-column: 1; grid-row: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.pay-month-list-item-heading .portal-status { grid-column: 2; grid-row: 1 / span 2; align-self: start; white-space: nowrap; }
.pay-month-list-item-month { grid-column: 1; grid-row: 2; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.pay-month-list-item small { grid-column: 1 / -1; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
.pay-month-preview { overflow: hidden; }
.pay-month-sheet-preview .timesheet-paper-header { align-items: flex-start; }
.pay-month-sheet-preview .portal-status { flex: 0 0 auto; height: fit-content; }
.pay-month-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
.pay-month-edit-table { min-width: 54rem; }
.pay-month-edit-actions { align-items: flex-start; }
.pay-month-download { white-space: normal; }
.pay-month-download-status { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 900px) {
  .pay-month-layout { grid-template-columns: minmax(250px, .75fr) minmax(0, 1.65fr); }
  .pay-month-preview { position: sticky; top: 1rem; }
}

@media (max-width: 700px) {
  .pay-month-layout { gap: .75rem; }
  .pay-month-list { max-height: 360px; overflow-y: auto; padding-right: .1rem; }
  .pay-month-preview { padding: .9rem; }
  .pay-month-edit-table { display: table; min-width: 54rem; }
  .pay-month-edit-table thead { display: table-header-group; }
  .pay-month-edit-table tbody { display: table-row-group; }
  .pay-month-edit-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .pay-month-edit-table th, .pay-month-edit-table td { display: table-cell; width: auto; padding: .5rem .45rem; border-bottom: 1px solid #e0e5dd; vertical-align: middle; }
  .pay-month-edit-table td::before { display: none; }
  .pay-month-edit-actions { display: grid; grid-template-columns: 1fr; gap: .55rem; }
  .pay-month-edit-actions .small-text { min-width: 0; }
}

.pay-month-edit-table tr.is-removed { opacity: .55; text-decoration: line-through; }
.pay-month-remove-day { white-space: nowrap; padding: .42rem .55rem; font-size: .83rem; }
