:root {
  --bg: #f1f2f7;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-strong: #ffffff;
  --text: #1c2430;
  --muted: #536272;
  --line: #d8d9e8;
  --accent: #667eea;
  --accent-soft: #e8eaff;
  --warn: #c86f31;
  --shadow: 0 22px 55px rgba(45, 42, 80, 0.11);
  --bid-bg: linear-gradient(180deg, rgba(88, 62, 150, 0.16), rgba(248, 246, 255, 0.98));
  --bid-border: rgba(88, 62, 150, 0.28);
  --bid-inset: rgba(88, 62, 150, 0.12);
  --bid-rollup-bg: linear-gradient(180deg, rgba(88, 62, 150, 0.14), rgba(255, 255, 255, 0.92));
  --bid-rollup-border: rgba(88, 62, 150, 0.18);
  --line-bg: linear-gradient(180deg, rgba(229, 240, 255, 0.98), rgba(214, 231, 255, 0.95));
  --line-border: rgba(52, 93, 170, 0.22);
  --line-inset: rgba(52, 93, 170, 0.08);
  --line-category-bg: rgba(248, 252, 255, 0.9);
  --line-category-border: rgba(52, 93, 170, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(102, 126, 234, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(118, 75, 162, 0.15), transparent 24%),
    linear-gradient(180deg, #f8f8fc, #ececf5 52%, #f5f4fa);
  color: var(--text);
}

.page-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 20px 16px;
  border: 1px solid rgba(102, 126, 234, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 250, 0.88)),
    linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.06));
  box-shadow: var(--shadow);
}

.brand-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand-name {
  font-family: "Merriweather", Georgia, serif;
  font-weight: 700;
  font-size: 1.15rem;
}

.work-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}

.estimate-group {
  display: grid;
  gap: 8px;
  min-width: 300px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
  font-family: "Merriweather", Georgia, serif;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1;
}

.estimate-switcher span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.estimate-switcher select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

.estimate-manager-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.estimate-manager-actions .save-status {
  margin-left: 6px;
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.view-tabs {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.tab-button {
  border: 1px solid rgba(31, 39, 34, 0.08);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(255, 250, 243, 0.92);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.22);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-copy {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.panel {
  grid-column: span 6;
  background: var(--panel);
  border: 1px solid rgba(28, 36, 48, 0.08);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

dialog input {
  background: #fdfdff;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(41, 94, 82, 0.18);
  border-color: var(--accent);
}

.button,
.icon-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--accent);
  color: white;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(102, 126, 234, 0.22);
}

.button.secondary,
.icon-button {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

.button.small,
.icon-button {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(31, 39, 34, 0.08);
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1100px;
  background: rgba(255, 253, 248, 0.72);
}

#budgetTrackingTable {
  min-width: 1880px;
}

#laborTable,
#equipmentTable {
  min-width: 0;
  width: 100%;
  table-layout: auto;
}

#laborTable th:last-child,
#laborTable td:last-child,
#equipmentTable th:last-child,
#equipmentTable td:last-child {
  width: 1%;
  white-space: nowrap;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(31, 39, 34, 0.08);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: #eef0ff;
  z-index: 1;
  font-size: 0.9rem;
  color: var(--muted);
}

.pricing-total-row td {
  background: rgba(102, 126, 234, 0.1);
  border-top: 2px solid rgba(102, 126, 234, 0.16);
}

td[data-output] {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.equipment-cell {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.picker-button {
  border: 1px solid rgba(41, 94, 82, 0.18);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(41, 94, 82, 0.08);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.equipment-selection {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: normal;
}

.equipment-dialog {
  width: min(980px, calc(100vw - 32px));
  border: 1px solid rgba(41, 94, 82, 0.15);
  border-radius: 26px;
  padding: 22px;
  background: linear-gradient(180deg, #fdfdff, #ececf5);
  box-shadow: 0 28px 80px rgba(31, 39, 34, 0.18);
}

.pricing-dialog {
  width: min(96vw, 1800px);
  max-height: 92vh;
  border: 1px solid rgba(41, 94, 82, 0.15);
  border-radius: 26px;
  padding: 22px;
  background: linear-gradient(180deg, #fdfdff, #ececf5);
  box-shadow: 0 28px 80px rgba(31, 39, 34, 0.18);
}

.equipment-dialog::backdrop {
  background: rgba(24, 30, 26, 0.38);
  backdrop-filter: blur(3px);
}

.pricing-dialog::backdrop {
  background: rgba(24, 30, 26, 0.38);
  backdrop-filter: blur(3px);
}

.pricing-dialog-wrap {
  max-height: 74vh;
}

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

.dialog-search {
  display: block;
  margin-bottom: 14px;
}

.dialog-search span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.custom-directory-card {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.92);
  border: 1px solid rgba(31, 39, 34, 0.08);
}

.custom-directory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.custom-directory-header h3 {
  margin: 0;
  font-size: 1rem;
}

.custom-directory-grid {
  grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(120px, 1fr));
}

.equipment-table-action {
  text-align: left;
  padding-left: 6px;
  padding-right: 8px;
}

.select-equipment-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.bid-items {
  display: grid;
  gap: 10px;
}

.bid-card {
  border: 1px solid var(--bid-border);
  border-radius: 22px;
  padding: 18px;
  background: var(--bid-bg);
  box-shadow: inset 0 0 0 1px var(--bid-inset);
}

.review-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.bid-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drag-handle {
  border: 1px solid rgba(31, 39, 34, 0.12);
  border-radius: 10px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: grab;
}

.is-dragging-bid .drag-handle {
  cursor: grabbing;
}

.bid-drop-target {
  outline: 2px dashed rgba(102, 126, 234, 0.5);
  outline-offset: 4px;
}

.bid-header,
.line-header,
.category-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.proposal-export-copy {
  display: grid;
  gap: 14px;
}

.budget-notes-input {
  min-width: 220px;
}

.proposal-note {
  margin: 0;
  color: var(--muted);
}

.schedule-sheet {
  display: grid;
  gap: 14px;
}

.schedule-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 14px 16px;
  border: 1px solid rgba(31, 39, 34, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(240, 247, 255, 0.9));
  color: var(--muted);
}

.schedule-summary strong {
  color: var(--text);
}

.schedule-grid {
  display: grid;
  gap: 10px;
}

.schedule-row,
.schedule-head {
  display: grid;
  grid-template-columns: 72px minmax(220px, 1.2fr) 100px 100px 100px 120px minmax(260px, 2fr);
  gap: 10px;
  align-items: center;
}

.schedule-head {
  padding: 0 10px 6px;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.schedule-row {
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(31, 39, 34, 0.08);
  background: rgba(255, 253, 248, 0.92);
}

.schedule-row input {
  padding: 8px 10px;
  font-size: 0.92rem;
}

.schedule-cell-title strong {
  display: block;
}

.schedule-cell-title span {
  color: var(--muted);
  font-size: 0.92rem;
}

.schedule-track {
  position: relative;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(52, 93, 170, 0.18);
  background:
    repeating-linear-gradient(
      90deg,
      rgba(52, 93, 170, 0.06) 0,
      rgba(52, 93, 170, 0.06) calc(10% - 1px),
      rgba(255, 255, 255, 0.9) calc(10% - 1px),
      rgba(255, 255, 255, 0.9) 10%
    );
  overflow: hidden;
}

.schedule-bar {
  position: absolute;
  top: 6px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(90deg, #5568d3, #667eea);
  box-shadow: 0 8px 16px rgba(85, 104, 211, 0.22);
}

.schedule-bar.zero {
  width: 12px;
  min-width: 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, #1d4ed8, #2563eb);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.schedule-bar-label {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
}

.schedule-empty {
  padding: 18px;
  border: 1px dashed rgba(31, 39, 34, 0.18);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.schedule-sheet-expanded .schedule-row,
.schedule-sheet-expanded .schedule-head {
  grid-template-columns: 80px minmax(280px, 1.3fr) 120px 120px 120px 160px minmax(520px, 2.4fr);
}

@media (max-width: 1100px) {
  .schedule-head,
  .schedule-row,
  .schedule-sheet-expanded .schedule-row,
  .schedule-sheet-expanded .schedule-head {
    grid-template-columns: 72px minmax(220px, 1.2fr) 96px 96px 96px 120px minmax(320px, 2fr);
  }
}

.bid-meta p,
.line-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.bid-actions {
  display: flex;
  gap: 10px;
}

.grow-2 {
  grid-column: span 2;
}

.bid-grid,
.line-grid,
.line-cost-grid {
  margin-top: 14px;
}

.bid-notes {
  display: block;
  margin-top: 14px;
}

.rollup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.rollup-grid div,
.line-rollup {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bid-rollup-bg);
  border: 1px solid var(--bid-rollup-border);
}

.rollup-grid span,
.line-rollup span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.rollup-grid strong,
.line-rollup strong {
  font-size: 1.05rem;
}

.line-items {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.line-card {
  border: 1px solid var(--line-border);
  border-radius: 18px;
  padding: 16px;
  background: var(--line-bg);
  box-shadow: inset 0 0 0 1px var(--line-inset);
}

.category-block {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--line-category-bg);
  border: 1px solid var(--line-category-border);
}

.category-block h5 {
  margin: 0;
  font-size: 0.95rem;
}

.entry-table {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.entry-head,
.entry-row {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(80px, 1fr)) minmax(100px, 1fr) 88px;
  gap: 8px;
  align-items: center;
}

.equipment-grid {
  grid-template-columns: minmax(260px, 2fr) repeat(6, minmax(80px, 1fr)) minmax(100px, 1fr) 88px;
}

.simple-grid {
  grid-template-columns: minmax(220px, 2fr) minmax(80px, 0.75fr) minmax(80px, 0.75fr) minmax(110px, 0.9fr) minmax(120px, 1fr) 88px;
}

.entry-head {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.entry-name {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  align-items: center;
}

.entry-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.compact {
  padding: 8px 8px;
  font-size: 0.75rem;
}

.small-chip {
  padding: 8px 10px;
  font-size: 0.75rem;
}

.empty-state {
  margin: 8px 0 0;
  color: var(--muted);
}

.empty-state.large {
  padding: 18px;
  border-radius: 16px;
  background: rgba(41, 94, 82, 0.06);
}

.collapsed-preview {
  padding: 6px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(88, 62, 150, 0.12), rgba(248, 246, 255, 0.98));
  border: 1px solid rgba(88, 62, 150, 0.22);
  position: relative;
  min-height: 0;
}

.collapsed-preview strong,
.collapsed-preview span {
  display: block;
}

.collapsed-preview span {
  margin-top: 1px;
  color: var(--muted);
}

.collapsed-preview-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 118px;
  min-height: 30px;
}

.collapsed-preview-line strong,
.collapsed-preview-line span {
  display: inline;
  margin: 0;
}

.collapsed-preview-line span {
  white-space: normal;
}

.collapsed-bid-item {
  padding: 0;
  margin: 0;
}

.collapsed-expand-button {
  position: absolute;
  top: 6px;
  right: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.summary-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(118, 75, 162, 0.16), rgba(255, 255, 255, 0.93));
  border: 1px solid rgba(118, 75, 162, 0.18);
}

.summary-card h3 {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}

.summary-card p {
  margin: 0;
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 980px) {
  .topbar,
  .panel {
    grid-column: 1 / -1;
  }

  .work-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .grow-2 {
    grid-column: span 1;
  }

  .entry-head,
  .entry-row,
  .equipment-grid,
  .simple-grid {
    grid-template-columns: 1fr;
  }

  .entry-head {
    display: none;
  }

  .entry-name {
    grid-template-columns: 72px 1fr;
  }
}

.hero-account {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.save-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.save-status.saving {
  color: var(--warn);
}

.save-status.error {
  color: #b01f2c;
  font-weight: 600;
}

.rates-dialog-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

#ratesStatus {
  color: var(--muted);
  font-size: 0.88rem;
}

#laborRatesTable input,
#equipmentRatesTable input {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  font: inherit;
}

.line-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.line-card-collapsed {
  padding: 8px 14px;
}

.collapsed-line-row {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  padding-right: 96px;
  min-height: 30px;
}

.collapsed-line-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.collapsed-line-expand {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.bid-title-line h3,
.line-header h4 {
  margin: 0;
}

.collapsed-note {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
}

.collapsed-note:empty {
  display: none;
}

.appbar {
  background: linear-gradient(90deg, #5568d3, #667eea);
  color: #fff;
  box-shadow: 0 4px 16px rgba(85, 104, 211, 0.28);
}

.appbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.appbar .brand-name {
  color: #fff;
}

.account-menu-wrap {
  position: relative;
}

.account-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.65);
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.account-button:hover {
  background: rgba(255, 255, 255, 0.28);
}

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  min-width: 270px;
  z-index: 60;
}

.account-menu-label {
  margin: 10px 0 2px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.account-menu-label:first-child {
  margin-top: 0;
}

.account-menu-line {
  margin: 0;
  font-size: 0.95rem;
}

.account-join-code {
  font-weight: 700;
  letter-spacing: 0.08em;
}

.account-menu .button {
  margin-top: 14px;
  width: 100%;
}

.form-grid[hidden] {
  display: none;
}

.settings-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.settings-note:empty {
  display: none;
}

#estimateSwitcher {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  min-width: 220px;
  max-width: 340px;
}

.account-menu-muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  margin-left: 6px;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}

.line-grid {
  grid-template-columns: minmax(200px, 2.4fr) repeat(6, minmax(82px, 1fr));
}

.line-grid .grow-2 {
  grid-column: auto;
}

@media (max-width: 980px) {
  .line-grid {
    grid-template-columns: 1fr 1fr;
  }
}
