:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fd;
  --border: #d9dfef;
  --text: #111827;
  --muted: #59627a;
  --brand: #1f3b7a;
  --brand-2: #3056d3;
  --success: #1f9d68;
  --danger: #d64545;
  --shadow: 0 10px 30px rgba(31, 59, 122, 0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; font-family: Inter, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
body.estimator-modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--brand); color: white;
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 1.7rem; font-weight: 800; letter-spacing: .2px; }
.brand-mobile { display: none; }
.brand-full { display: inline; }
.nav-links { display: flex; gap: 10px; align-items: center; }

.estimator-nav #header-total {
  max-width: min(46vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
}


.container { width: min(1280px, 94vw); margin: 24px auto; }

@media (max-width: 900px) {
  .topbar {
    position: sticky;
    top: 0;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 10px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav-links {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .nav-links .btn, .nav-links .badge { white-space: nowrap; }
  .nav-links .btn { padding: 8px 10px; font-size: .95rem; }
  .estimator-nav #header-total { max-width: 34vw; }
  .container { width: min(1280px, 96vw); margin: 12px auto; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.btn {
  border: 1px solid transparent;
  background: var(--brand);
  color: white;
  border-radius: 10px;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary {
  background: white; color: var(--brand); border-color: var(--border);
}
.btn.ghost {
  background: transparent; color: white; border-color: rgba(255,255,255,0.35);
}
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.warning { background: #e8c24a; color: #1f315d; }

.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; padding: 30px; }
.hero h1 { font-size: 2.3rem; margin: 0 0 10px; }
.hero p { color: var(--muted); font-size: 1.08rem; margin-bottom: 20px; }
.pricing { display: grid; gap: 12px; }
.pricing .tier { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.tier h3 { margin: 0 0 4px; }

.grid-3 { display: grid; grid-template-columns: 300px 1fr 330px; gap: 14px; align-items: start; }
.panel { padding: 16px; }
.section-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 8px; }
.muted { color: var(--muted); }
.site-footer {
  margin: 18px auto 22px;
  max-width: 1200px;
  padding: 0 20px;
  text-align: center;
  color: #6b7ca7;
  font-size: 12px;
}

.field { margin-bottom: 12px; }
label { display: block; margin-bottom: 5px; color: #27314f; font-size: .92rem; font-weight: 600; }
input, textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: white;
}
textarea { min-height: 92px; resize: vertical; }


.quote-materials-text {
  overflow: hidden;
  white-space: pre-wrap;
}

.module-list { margin-top: 10px; display: grid; gap: 8px; }

.module-pill {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.module-pill.active {
  border-color: #9db5ff;
  background: #eef3ff;
}
.module-pill-title {
  border: 0;
  background: transparent;
  color: #1f315d;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.module-pill-title:hover { text-decoration: underline; }


@media (max-width: 900px) {
  .module-pill {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-width: 0;
  }
  .module-pill-title {
    display: -webkit-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    line-height: 1.25;
    max-height: calc(1.25em * 2);
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .module-pill-title:hover,
  .module-pill-title:active,
  .module-pill-title:focus {
    text-decoration: none;
  }
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 18px;
  color: var(--muted);
  background: #fafcff;
}

.module-card { padding: 16px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; background: white; }
.module-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.module-head h3 { margin: 0; }

.task-lines { display: grid; gap: 10px; }
.task-line {
  border: 2px solid #b53737;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}
.task-line-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.task-inline-row { gap: 10px; align-items: end; }
.task-meta { min-width: 0; }
.task-meta-grow { flex: 1; }
.task-meta-unit { width: 110px; }
.task-meta-qty { width: 140px; }
.task-title-input { max-width: 100%; }
.delete-x {
  border: 1px solid #f1b4b4;
  color: #c93636;
  background: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}
.task-line-body {
  display: grid;
  gap: 10px;
}
.task-line-body label {
  font-size: .78rem;
  margin-bottom: 4px;
  color: #4a577a;
}
.task-core-row { display:none; }
.task-meta { display: grid; }
.resource-rows {
  display: grid;
  gap: 8px;
}
.resource-row {
  display: grid;
  grid-template-columns: 100px 1fr 120px 34px;
  gap: 10px;
  align-items: center;
}
.resource-row label {
  font-weight: 700;
  margin: 0;
}
.resource-row strong {
  text-align: right;
}
.resource-row .chip-btn { font-size: 0.9rem; }
.task-total {
  text-align: right;
  background: transparent;
  border: 1px solid #e8cc57;
  border-radius: 10px;
  padding: 7px;
}
.task-total small {
  display: block;
  color: #5f6d91;
  font-size: 0.76rem;
  margin-top: 4px;
}

@media (max-width: 1100px) {
  .resource-row { grid-template-columns: 1fr; }
  .task-inline-row { flex-wrap: wrap; }
  .task-meta-grow { width: 100%; }
}


@media (max-width: 900px) {
  .resource-row {
    grid-template-columns: 62px minmax(0, 1fr) 34px;
    grid-template-rows: auto auto;
    gap: 6px 8px;
    align-items: center;
  }
  .resource-row label {
    font-size: 0.82rem;
    grid-column: 1;
    grid-row: 1;
    align-self: center;
  }
  .resource-row .chip-btn {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.25;
    padding: 8px 10px;
  }
  .resource-row strong {
    grid-column: 2;
    grid-row: 2;
    min-width: 88px;
    max-width: 100%;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    justify-self: end;
    font-size: 0.88rem;
    line-height: 1.15;
  }
  .resource-row .line-remove {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
    justify-self: center;
  }
  .resource-extra-line {
    grid-template-columns: minmax(0, 1fr) auto 34px;
    grid-template-rows: auto;
    align-items: center;
  }
  .resource-extra-line label {
    display: none;
  }
  .resource-extra-line .chip-btn {
    grid-column: 1;
    grid-row: 1;
  }
  .resource-extra-line strong {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    min-width: 70px;
  }
  .resource-extra-line .line-remove {
    grid-column: 3;
    grid-row: 1;
  }
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid #e6eaf5; padding: 8px; text-align: left; }
.table th { color: #2f3a57; background: #f6f8ff; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }

.right-summary { position: sticky; top: 74px; }
.kpis { display: grid; gap: 8px; margin-bottom: 10px; }
.kpi { background: #f7f9ff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display:flex; justify-content:space-between; }
.total { font-size: 1.2rem; font-weight: 800; }

.chart-row { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 10px 0; }
.donut {
  --mat: 55;
  --lab: 30;
  --plant: 15;
  --waste: 8;
  width: 130px; height: 130px; border-radius: 50%;
  background:
    conic-gradient(
      #2f6bff 0 calc(var(--mat) * 1%),
      #f5c542 0 calc((var(--mat) + var(--plant)) * 1%),
      #2fbf5b 0 calc((var(--mat) + var(--plant) + var(--lab)) * 1%),
      #161616 0 calc((var(--mat) + var(--plant) + var(--lab) + var(--waste)) * 1%),
      #d93636 0 100%
    );
  position: relative;
}
.donut::after {
  content: "";
  position: absolute; inset: 24px;
  background: #fff; border-radius: 50%;
}

.mini-bars { flex: 1; display: grid; gap: 7px; }
.bar-line { background: #eef2ff; border-radius: 8px; overflow: hidden; height: 14px; }
.bar-line > span { display: block; height: 100%; background: linear-gradient(90deg, #1f3b7a, #3766df); }

.badge { border-radius: 999px; padding: 4px 9px; font-size: .82rem; font-weight: 700; display: inline-block; }
.badge.success { background: #dff5ea; color: #0c7c4a; }
.badge.info { background: #dfe9ff; color: #284ba8; }

.dashboard-grid { display: grid; gap: 16px; }
.projects-head { display:flex; justify-content:space-between; align-items:center; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions select { min-width: 220px; max-width: 280px; }


.admin-tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom:14px; }
.admin-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }

@media (max-width: 1120px) {
  .grid-3 { grid-template-columns: 1fr; }
  .right-summary { position: static; }
  .hero { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
}

.chip-btn {
  border: 1px solid #e6c755;
  background: transparent;
  color: #1f315d;
  border-radius: 18px;
  padding: 7px 10px;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.15;
  cursor: pointer;
}
.chip-btn:hover { background: #fff8d8; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  position: relative;
  width: min(720px, 94vw);
  max-height: 80vh;
  overflow: auto;
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.picker-list { display: grid; gap: 8px; }
.picker-list { max-height: 62vh; overflow: auto; padding-right: 10px; position: relative; }
.picker-list { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }

/* Removed modal scroll arrow hints: they were mispositioned and non-interactive. */

#module-backdrop { overflow: hidden; }
#module-backdrop .modal { overflow: hidden; }
.builder-task-lines-panel { min-height: 280px; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; align-content: start; }
.quick-lib-editor-full { width: 100%; }
.quick-lib-editor-full .table { min-width: 1250px; }
.quick-lib-name-cell { display: grid; gap: 6px; }
.quick-lib-google { font-size: .84rem; color: #1f4aa8; text-decoration: underline; }
.quick-lib-google:hover { color: #17367a; }
.admin-optional > summary { cursor: pointer; }
#rams-body td { vertical-align: top; }
#rams-body td:first-child { width: 48px; font-weight: 700; color: #1f315d; }

.picker-item {
  display: flex;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  cursor: pointer;
}
.picker-item:hover { background: #f5f8ff; }
.picker-item.active { border-color:#9db5ff; background:#eef3ff; }
.picker-item-split { align-items: center; gap: 10px; }
.picker-item-copy { display: grid; gap: 2px; min-width: 0; }
.picker-item-copy span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.picker-item-split {
  align-items: center;
  gap: 10px;
}
.picker-item-split > span { flex: 1; }

.modal-corner-close {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 2px solid #d92d20;
  background: #fff5f5;
  color: #d92d20;
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 1000;
}

.modal-corner-close:hover {
  background: #ffe6e6;
}

.admin-stack { display: grid; gap: 14px; }
.admin-sections { display: grid; gap: 14px; }
.admin-list { margin: 10px 0 0; color: #2f3a57; }
.admin-list li { margin: 6px 0; }

.admin-tools-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.admin-tool h4 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

@media (max-width: 1120px) {
  .admin-tools-grid { grid-template-columns: 1fr; }
}


/* Remove number input spinner arrows for smoother editing */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}


.editable-outline {
  background: transparent !important;
  border: 1px solid #e1c557 !important;
  border-radius: 18px !important;
}
.qty-outline {
  border-color: #b53737 !important;
}

.modal .field input#picker-search {
  background: #fffef0;
  border: 1px solid #d7deef;
}


@media (max-width: 900px) {
  .table .actions { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; }
  .table .actions .btn { width: auto; white-space: nowrap; }
  .projects-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .nav-links { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .nav-links .btn, .nav-links .badge { white-space: nowrap; }
  .estimator-nav { overflow-x: visible; }
  .estimator-nav .btn { min-width: 96px; }
  .brand { font-size: 1.15rem; }
  .brand-full { display: inline; }
  .brand-mobile { display: none; }
  .table td.actions { min-width: 220px; }
}

.cost-blue .table th { background: #eaf3ff; }
.cost-blue .table td { background: #f7fbff; }
.print-page-break { break-after: page; page-break-after: always; }

.table-scroll { overflow-x: auto; }

.module-mini-scroll {
  max-height: 320px;
  overflow-y: auto;
}
.module-mini-scroll .table {
  margin-top: 0;
}

.doc-meta { display:flex; justify-content:space-between; align-items:center; gap:12px; margin:10px 0 12px; }
.logo-placeholder { border:1px dashed var(--border); border-radius:10px; padding:8px 10px; color:var(--muted); min-width:180px; }

.doc-date-field { display:grid; gap:4px; justify-items:end; text-align:right; }
.doc-date-field input[type="date"] { min-width: 170px; text-align:right; }
@media (max-width:900px){
  .doc-date-field { justify-items:start; text-align:left; }
  .doc-date-field input[type="date"] { text-align:left; min-width: 0; width: 100%; }
}

.gantt-scroll { overflow-x:auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior-x: contain; }
.gantt-table { min-width: 720px; width: 100%; touch-action: auto; table-layout: auto; }

.chart-legend { display:grid; gap:6px; margin-top:8px; }
.legend-item { display:flex; align-items:center; justify-content:space-between; gap:8px; color:#425176; }
.legend-dot { width:10px; height:10px; border-radius:2px; display:inline-block; margin-right:8px; }
.legend-item strong { margin-left:auto; }
.legend-dot.mat { background:#2f6bff; }
.legend-dot.plant { background:#f5c542; }
.legend-dot.labour { background:#2fbf5b; }
.legend-dot.wastage { background:#161616; }
.legend-dot.profit { background:#d93636; }

.gantt-table th, .gantt-table td { white-space: nowrap; }
.gantt-table input { min-width: 92px; width: 100%; }
.gantt-table .bar-cell { background: #dce8ff; }

.programme-date-ruler {
  display: grid;
  gap: 0;
  border: 1px solid #d6deef;
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 10px;
  background: #f8fbff;
  margin-left: 366px;
  width: calc(100% - 366px);
}
.programme-date-ruler .ruler-day {
  font-size: 11px;
  text-align: center;
  padding: 4px 2px;
  border-right: 1px solid #d6deef;
  color: #23355f;
  white-space: nowrap;
}
.programme-date-ruler .ruler-day:last-child { border-right: 0; }
.programme-date-ruler .ruler-day.weekend {
  background: #ffe7e7;
  color: #8d2a2a;
}
.gantt-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(1px, 1fr);
  pointer-events: none;
  z-index: 1;
}
.gantt-grid .gantt-day {
  border-right: 1px solid rgba(24, 48, 92, 0.18);
}
.gantt-grid .gantt-day.weekend {
  background: rgba(255, 210, 210, 0.45);
  border-right-color: rgba(162, 55, 55, 0.26);
}
.gantt-grid .gantt-day:last-child { border-right: 0; }
.gantt-bar { z-index: 2; }
.gantt-table tr.active-row td { background: #f3f7ff; }
.task-inline-row .delete-x { align-self: center; }

.timeline-cell { padding: 4px !important; }
.gantt-track { position: relative; height: 20px; background: #f2f5ff; border-radius: 10px; touch-action: none; }
.gantt-bar { position: absolute; top: 2px; height: 16px; border-radius: 10px; cursor: grab; touch-action: none; }
.drag-handle { position:absolute; top:0; bottom:0; width:10px; touch-action: none; }
.drag-handle.left { left:0; cursor: ew-resize; }
.drag-handle.right { right:0; cursor: ew-resize; }
.drag-handle.mid { left:10px; right:10px; cursor: move; }
.programme-compact th, .programme-compact td { padding-top: 6px; padding-bottom: 6px; }
@media (max-width: 900px) {
  .programme-compact th, .programme-compact td { padding-top: 5px; padding-bottom: 5px; }
  .gantt-track { height: 18px; touch-action: pan-x pan-y; }
  .gantt-bar { height: 14px; touch-action: pan-x pan-y; }
  .drag-handle { touch-action: none; }
  .drag-handle.mid { min-width: 14px; }
  .gantt-scroll { max-width: 100%; }
}

@media print { .gantt-scroll { overflow: visible !important; } .gantt-track, .gantt-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; } .gantt-track { border: 1px solid #d2dbef; } .gantt-table { min-width: 0 !important; width: 100% !important; table-layout: fixed; font-size: 9px; } .gantt-table th, .gantt-table td { padding: 2px 3px !important; } }

.cost-summary-cards {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.cost-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 1.4fr;
  gap: 10px;
  border: 1px solid #cfe0ff;
  border-radius: 12px;
  background: #f4f9ff;
  padding: 12px;
}

.cost-card-left,
.cost-card-right {
  background: #dfeeff;
  border-radius: 10px;
  padding: 10px;
}

.cost-chip {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  color: #2f5eb8;
  background: #edf4ff;
  border: 1px solid #b9d1ff;
  border-radius: 999px;
  padding: 3px 8px;
  margin-bottom: 6px;
}

.cost-card-left h3 {
  margin: 0 0 6px;
  color: #1e315c;
}

.cost-task-count {
  color: #51638b;
  font-size: .9rem;
}

.cost-card-right {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.cost-metric {
  background: #f7fbff;
  border: 1px solid #c9ddff;
  border-radius: 9px;
  padding: 8px;
  display: grid;
  gap: 3px;
}

.cost-metric span {
  color: #5a6f99;
  font-size: .8rem;
}

.cost-metric strong {
  color: #1e315c;
}

.cost-metric.time {
  background: #e8f4ff;
}

.cost-summary-totals {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 8px;
}

.cost-total-box {
  background: #e3f0ff;
  border: 1px solid #bfd7ff;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.cost-total-box span { color: #4f668f; font-size: .82rem; }
.cost-total-box strong { color: #173160; }

@media (max-width: 900px) {
  .cost-card { grid-template-columns: 1fr; }
  .cost-card-right { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .cost-summary-totals { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}

@media (max-width: 640px) {
  .kpi { align-items: flex-start; gap: 8px; }
  .kpi strong, .kpi span, .total { font-size: 0.95rem; line-height: 1.2; }
  #header-total { font-size: 0.88rem; max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .amount, .cost-total-box strong { font-size: 0.95rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .cost-total-box span { font-size: 0.78rem; }
}

.project-cards-mobile { display: none; margin-top: 10px; }
.project-card { border:1px solid var(--border); border-radius:12px; padding:10px; background:#fff; margin-bottom:8px; }

@media (max-width: 900px) {
  .project-cards-mobile { display:block; }
  .dashboard-grid .table-scroll { display:none; }
}

.weekend-col { background: #ffe7e7 !important; }
.daily-programme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.daily-programme-day {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  background: #f8fbff;
}
.daily-programme-day.weekend-day {
  background: #fff1f1;
  border-color: #f2c8c8;
}
.daily-programme-day h4 { margin: 0 0 6px; font-size: .92rem; color: #2f3a57; }

.weekend-row td { background: #fff3f3 !important; }


.calendar-week { border:1px solid var(--border); border-radius:10px; padding:8px; margin-bottom:10px; background:#f8fbff; }
.calendar-week h4 { margin:0 0 8px; color:#2f3a57; }
.calendar-week-grid { display:grid; grid-template-columns:repeat(7,minmax(120px,1fr)); gap:8px; }
.calendar-slot { border:1px solid #d7e2f7; border-radius:8px; background:#fff; padding:6px; min-height:86px; }
.calendar-slot-head { font-size:.8rem; color:#465577; margin-bottom:6px; }
.calendar-slot-body { display:grid; gap:4px; }
.calendar-chip { display:block; font-size:.78rem; background:#eef3ff; border-radius:6px; padding:3px 6px; }

@media (max-width: 900px) {
  .calendar-week-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media print {
  .cost-card, .cost-card-left, .cost-card-right, .cost-total-box, .daily-programme-day, .calendar-week, .calendar-slot, .project-card {
    background: #fff !important;
    border: 1px solid #d9d9d9 !important;
    box-shadow: none !important;
  }
  .cost-card-right { grid-template-columns: repeat(2, minmax(120px,1fr)); }
  .calendar-week-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
}


.gantt-table th { border-right: 1px solid #d6deef; }
.gantt-table th.weekend-col { border-right: 1px solid #e2bcbc; }

@media (max-width: 900px) {
  #module-backdrop .modal { width: min(98vw, 98vw); max-height: 88vh; padding: 12px; }
  #module-library-list .picker-item-split { flex-direction: column; align-items: stretch; }
  #module-library-list .picker-item-split .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  #module-library-list .picker-item-split .btn { width: 100%; }
}

.admin-builder-pairs { display:grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 900px) { .admin-builder-pairs { grid-template-columns: 1fr; } }

#builder-task-lines .picker-item { align-items: flex-start; }
#builder-task-lines .picker-item .actions { display:flex; gap:8px; }

.resource-extra-lines { margin: 2px 0 8px 0; display: grid; gap: 8px; }
.resource-extra-line label { visibility: hidden; }
.resource-extra-line .chip-btn { font-size: 0.9rem; font-weight: 600; }
.chip-btn-static { cursor: default; }
.chip-btn-static:hover { background: transparent; }

#builder-extra-backdrop { z-index: 40; }
#builder-picker-backdrop { z-index: 80; }
#builder-picker-backdrop .modal { max-height: 88vh; }

.admin-optional summary { cursor:pointer; font-weight:700; color:#1f315d; }
.admin-optional[open] summary { margin-bottom:8px; }

.line-remove { border:1px solid #e6b9b9; background:#fff; color:#b42318; border-radius:10px; width:30px; height:30px; font-weight:700; cursor:pointer; }
.line-remove:hover { background:#fff2f2; }

@media print {
  @page { margin: 12mm; }
  html, body { background: #fff !important; }
  .topbar, .nav-links, .actions, [data-print-doc], [data-share-doc], .btn, .module-list, .right-summary, #module-backdrop, #picker-backdrop {
    display: none !important;
  }
  .container { width: 100% !important; margin: 0 !important; }
   .card, .panel, .cost-card, .cost-total-box, .daily-programme-day, .calendar-week, .calendar-slot, .gantt-table {
    break-inside: avoid-page;
    page-break-inside: avoid;
    box-shadow: none !important;
  }
  .table { break-inside: auto !important; page-break-inside: auto !important; }
  .table tr { break-inside: avoid; page-break-inside: avoid; }
  .table-scroll, .gantt-scroll { overflow: visible !important; max-height: none !important; }
  input, textarea, select { border: 0 !important; background: transparent !important; }
  .quote-materials-text {
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
  body::after { content: none !important; }
}


.rams-meta { display:flex; gap:16px; flex-wrap:wrap; padding:8px 10px; border:1px solid var(--border); border-radius:8px; background:#f8fbff; margin-top:10px; }
.rams-hs-policy { white-space: pre-wrap; line-height: 1.5; color:#1f315d; }
.rams-pro th, .rams-pro td { font-size:.82rem; vertical-align: top; }
.rams-pro td:nth-child(5), .rams-pro td:nth-child(6), .rams-pro td:nth-child(7),
.rams-pro td:nth-child(9), .rams-pro td:nth-child(10), .rams-pro td:nth-child(11) { text-align:center; font-weight:700; }
@media print {
  .rams-pro th, .rams-pro td { font-size:10px !important; }
}


/* Programme print-safe layout */
#programme-print { display: none; }
.mini-gantt-track { position: relative; min-height: 28px; border: 1px solid #d6deef; border-radius: 8px; background: #f8fbff; overflow: hidden; }
.mini-gantt-weekend { position:absolute; top:0; bottom:0; background: rgba(255, 220, 220, 0.45); border-right:1px solid rgba(173, 92, 92, 0.3); z-index:1; }
.mini-gantt-bar { position: absolute; top: 5px; height: 18px; border-radius: 8px; opacity: .92; }

@media print {
  .card.panel { break-inside: auto !important; page-break-inside: auto !important; }
  .gantt-scroll, #add-task-above, #add-task-below, #remove-task-line { display: none !important; }
  #programme-print { display: block !important; }
  #programme-print .programme-print-page { page-break-after: always; break-after: page; }
  #programme-print .programme-print-page:last-child { page-break-after: auto; break-after: auto; }
  .programme-print-table { width: 100% !important; table-layout: fixed; }
  .programme-print-table th, .programme-print-table td { font-size: 10px !important; padding: 5px 6px !important; white-space: normal !important; vertical-align: top; }
  .programme-print-table .print-task-meta { width: 38%; }
  .programme-print-table .mini-gantt-track { min-height: 24px; }
  .mini-gantt-track, .mini-gantt-bar, .mini-gantt-weekend { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .programme-print-table .mini-gantt-bar { top: 4px; height: 15px; }
}

@media (max-width: 1100px) {
  .programme-date-ruler {
    margin-left: 0;
    width: 100%;
  }
}

.print-page-num { display:none; }
.print-textarea-value { display:none; }
.print-input-value { display:none; }
@media print {
  .print-page-num { display:none !important; }
  .print-page-break { page-break-after: always; break-after: page; }
  .print-page-break:last-of-type { page-break-after: auto; break-after: auto; }
  .print-hide { display: none !important; }
  .ce-company-footer-line { display: block !important; }
  textarea {
    overflow: hidden !important;
    resize: none !important;
    min-height: 1px !important;
    height: auto !important;
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  textarea::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }
  input {
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  textarea + .print-textarea-value {
    display: block !important;
    white-space: pre-wrap;
    line-height: 1.35;
    margin-top: 2px;
    color: #111827;
  }
  input + .print-input-value {
    display: block !important;
    white-space: pre-wrap;
    line-height: 1.35;
    margin-top: 2px;
    color: #111827;
  }
  textarea { display: none !important; }
  input:not([type="checkbox"]):not([data-payment-label]):not([data-payment-amount]) { display: none !important; }
  .table-scroll { overflow: visible !important; max-height: none !important; }
  #quote-cancellation-section { font-size: 12px !important; }
  #quote-cancel-notice { gap: 1px !important; }
  #quote-cancel-other { min-height: 42px !important; }
}

/* PDF export layout helper */
body.ce-pdf-export .grid-3 { grid-template-columns: 1fr !important; }
body.ce-pdf-export .right-summary { position: static !important; }
body.ce-pdf-export .container {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
body.ce-pdf-export.ce-pdf-quote .container,
body.ce-pdf-export.ce-pdf-quote main {
  width: 100% !important;
  max-width: none !important;
  margin: 0 auto !important;
  padding: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}
body.ce-pdf-export.ce-pdf-quote .card.panel {
  width: min(92%, 860px) !important;
  max-width: 860px !important;
  border: 1px solid #d2dced !important;
  border-radius: 12px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}
html.ce-pdf-export,
body.ce-pdf-export { overflow: visible !important; }
body.ce-pdf-export main,
body.ce-pdf-export .card,
body.ce-pdf-export .panel,
body.ce-pdf-export .module-card,
body.ce-pdf-export .cost-card,
body.ce-pdf-export .cost-total-box {
  width: 100% !important;
  max-width: none !important;
  break-inside: auto;
  page-break-inside: auto;
}
body.ce-pdf-export .print-page-break {
  page-break-after: auto !important;
  break-after: auto !important;
}
body.ce-pdf-export .card.panel {
  margin-bottom: 10px !important;
}
body.ce-pdf-export .topbar,
body.ce-pdf-export .nav-links,
body.ce-pdf-export .actions,
body.ce-pdf-export .doc-actions,
body.ce-pdf-export [data-print-doc],
body.ce-pdf-export [data-save-pdf],
body.ce-pdf-export [data-share-doc] {
  display: none !important;
}
body.ce-pdf-export textarea {
  display: none !important;
}
body.ce-pdf-export textarea + .print-textarea-value {
  display: block !important;
  white-space: pre-wrap;
  line-height: 1.35;
  color: #111827;
}
body.ce-pdf-export input + .print-input-value {
  display: block !important;
  white-space: pre-wrap;
  line-height: 1.35;
  color: #111827;
}
body.ce-pdf-export.ce-pdf-quote input:not([type="checkbox"]):not([data-payment-label]):not([data-payment-amount]) {
  display: none !important;
}
body.ce-pdf-export input[data-payment-label],
body.ce-pdf-export input[data-payment-amount] {
  border: 0 !important;
  background: transparent !important;
}
body.ce-pdf-export .gantt-scroll,
body.ce-pdf-export .table-wrap,
body.ce-pdf-export .table-scroll,
body.ce-pdf-export .cost-table-wrap {
  overflow: visible !important;
  max-height: none !important;
}
body.ce-pdf-export main,
body.ce-pdf-export .card,
body.ce-pdf-export .module-card,
body.ce-pdf-export .task-lines {
  max-height: none !important;
  height: auto !important;
}


body.ce-pdf-export .gantt-table,
body.ce-pdf-export .programme-print-table,
body.ce-pdf-export #boq-table,
body.ce-pdf-export .table {
  width: 100% !important;
  max-width: none !important;
}
body.ce-pdf-export .gantt-table,
body.ce-pdf-export .programme-print-table {
  min-width: 0 !important;
  table-layout: fixed !important;
}


#manual-manager-backdrop .modal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#manual-manager-backdrop .modal .field {
  flex: 0 0 auto;
}
#manual-manager-list {
  flex: 1 1 auto;
  min-height: 220px;
  max-height: none;
  overflow: auto;
}
#manual-manager-backdrop .modal .actions {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  background: #fff;
  padding-top: 8px;
}


@media (max-width: 900px) {
  .task-inline-row {
    display: grid;
    grid-template-columns: 1fr 1fr 44px;
    gap: 8px;
    align-items: end;
  }
  .task-inline-row .task-meta-unit,
  .task-inline-row .task-meta-qty {
    width: auto;
  }
  .task-inline-row .task-meta-qty {
    grid-column: 1 / span 2;
  }
  .task-inline-row .delete-x {
    grid-column: 3;
    grid-row: 2;
    align-self: end;
    justify-self: end;
    width: 34px;
    height: 34px;
  }
}

@media print {
  .cost-summary-cards { display:block !important; }
  .cost-card { break-inside: avoid-page !important; page-break-inside: avoid !important; margin-bottom: 8mm !important; }
  #quote-module-fields .field { break-inside: avoid-page; page-break-inside: avoid; }
  .print-textarea-value { font-family: inherit; font-size: inherit; }
}
