:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --surface-warm: #fff7ed;
  --line: #e1e7e4;
  --line-strong: #cbd6d1;
  --text: #111816;
  --muted: #6f7d78;
  --soft-text: #50645d;
  --brand: #0f6b59;
  --brand-strong: #064f42;
  --brand-dark: #0a4f41;
  --brand-tint: #e8f4f0;
  --accent-green: #14b8a6;
  --accent: #b45f35;
  --accent-soft: #f5e4d8;
  --gold: #a17316;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --ok: #1d7a43;
  --ok-soft: #e3f3e9;
  --shadow: 0 8px 24px rgba(15, 33, 27, 0.06);
  --shadow-soft: 0 2px 12px rgba(15, 33, 27, 0.05);
  --radius: 10px;
  --sidebar: 220px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 89, 0.05), transparent 28rem),
    var(--bg);
  font-size: 13.5px;
  line-height: 1.42;
}

button,
input,
select,
textarea {
  font: inherit;
}

select {
  padding-right: 28px;
  text-overflow: ellipsis;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  --sidebar: 64px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  padding: 18px 14px;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 9px;
  align-items: center;
  padding: 0 0 18px;
}

.sidebar-collapsed .brand-lockup {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 8px;
}

.sidebar-collapsed .brand-lockup > div:not(.brand-mark),
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-link span:last-child {
  display: none;
}

.sidebar-collapsed .sidebar {
  padding: 16px 8px;
}

.sidebar-collapsed .nav-link {
  grid-template-columns: 1fr;
  justify-items: center;
  width: 44px;
  margin: 0 auto;
  padding: 8px;
}

.sidebar-collapsed .sidebar-toggle {
  position: static;
  width: 34px;
  min-width: 34px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  box-shadow: 0 8px 18px rgba(15, 107, 89, 0.18);
}

.brand-title {
  font-size: 15px;
  font-weight: 750;
  line-height: 1.15;
  white-space: nowrap;
}

.nav-section {
  margin: 8px 0 16px;
}

.nav-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  padding: 8px 8px;
  text-transform: uppercase;
}

.nav-link {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--soft-text);
  padding: 7px 8px;
  text-align: left;
}

.nav-link span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-sidebar-toggle {
  display: none;
}

.nav-link:hover,
.nav-link.active {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  box-shadow: 0 8px 16px rgba(15, 107, 89, 0.16);
}

.nav-link.active .nav-icon {
  color: #fff;
}

.nav-icon {
  width: 26px;
  min-width: 26px;
  height: 24px;
  display: grid;
  place-items: center;
  color: var(--brand);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 440px) auto;
  gap: 14px;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 248, 247, 0.92);
  backdrop-filter: blur(14px);
  padding: 14px 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
}

.topbar-search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search input {
  min-height: 36px;
  padding-left: 34px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.topbar-search::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  color: var(--muted);
  font-weight: 800;
}

.main {
  min-width: 0;
}

.content {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 18px 22px 42px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar .btn {
  flex: 0 0 auto;
}

.cloud-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border-color: rgba(15, 107, 89, 0.2);
  background: linear-gradient(135deg, rgba(232, 244, 240, 0.96), rgba(255, 255, 255, 0.98));
}

.cloud-banner p {
  margin: 3px 0 0;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.grid.sidebar-layout {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
}

.collapsible-panel > summary {
  cursor: pointer;
  list-style: none;
}

.collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel:not([open]) .collapse-indicator {
  transform: rotate(-90deg);
}

.collapse-indicator {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 13px 15px;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 720;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 14px;
}

.compact-panels .panel-body {
  padding: 12px;
}

.workflow-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.workflow-step {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--soft-text);
  padding: 4px 8px;
  font-weight: 720;
  font-size: 12px;
}

.workflow-step span {
  display: inline-block;
  min-width: 18px;
  margin-right: 5px;
  color: var(--brand);
  font-size: 11px;
}

.workflow-step.active,
.workflow-step.done {
  border-color: #9cc7b6;
  background: #edf6f2;
  color: var(--text);
}

.cost-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.cost-guide div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  padding: 9px;
}

.cost-guide strong,
.cost-guide span {
  display: block;
}

.cost-guide span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.cost-modal-form {
  display: grid;
  gap: 10px;
}

.cost-modal-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 10px;
}

.cost-modal-section h3 {
  margin: 0 0 4px;
  font-size: 14px;
  line-height: 1.2;
}

.cost-modal-section p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.internal-summary-grid {
  align-items: stretch;
}

.internal-entry-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #fbfcfa;
}

.survey-group-title {
  margin-top: 6px;
  color: var(--brand-strong);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand-strong);
  padding: 0;
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.service-manager {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 10px;
  margin-bottom: 12px;
}

.service-manager-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.service-manager-controls select {
  width: min(360px, 42vw);
}

.service-chip-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.service-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border: 1px solid #b8d6ca;
  border-radius: 999px;
  background: #edf6f2;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.inline-controls {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.8fr);
  gap: 6px;
  margin-top: 6px;
}

.compact-select,
.compact-toolbar select {
  width: auto;
  max-width: 260px;
}

.smart-quick-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 260px);
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.smart-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ede8;
}

.smart-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.smart-quick-table table {
  min-width: 720px;
}

.smart-quick-table th:first-child,
.smart-quick-table td:first-child {
  width: 44px;
  text-align: center;
}

.smart-quick-table th:nth-child(2),
.smart-quick-table td:nth-child(2) {
  width: 210px;
}

.smart-quick-table th:nth-child(3),
.smart-quick-table td:nth-child(3) {
  width: 96px;
}

.smart-quick-table th:nth-child(5),
.smart-quick-table td:nth-child(5),
.smart-quick-table th:nth-child(6),
.smart-quick-table td:nth-child(6) {
  width: 96px;
}

.smart-quick-table tr.is-added td {
  background: #f4faf7;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.dense-table {
  table-layout: fixed;
  border-collapse: collapse;
}

.nowrap,
.print-nowrap,
.money-cell,
.number-cell,
.action-cell {
  white-space: nowrap;
}

.money-cell,
.number-cell {
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-cell {
  width: 1%;
}

.truncate,
.truncate-field {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boq-table {
  min-width: 1320px;
}

.boq-col-no {
  width: 46px;
}

.boq-col-item {
  width: 360px;
}

.boq-col-qty {
  width: 78px;
}

.boq-col-cost {
  width: 124px;
}

.boq-col-price {
  width: 140px;
}

.boq-col-vat {
  width: 128px;
}

.boq-col-markup {
  width: 142px;
}

.boq-col-total,
.boq-col-profit {
  width: 124px;
}

.boq-col-client {
  width: 92px;
}

.boq-col-actions {
  width: 82px;
}

.supplier-draft-table {
  min-width: 1180px;
}

.project-table {
  min-width: 760px;
}

.boq-main th,
.boq-main td {
  font-size: 12px;
  overflow: hidden;
}

.boq-main td:nth-child(1),
.boq-main td:nth-child(3),
.boq-main td:nth-child(4),
.boq-main td:nth-child(5),
.boq-main td:nth-child(6),
.boq-main td:nth-child(7),
.boq-main td:nth-child(8),
.boq-main td:nth-child(9),
.boq-main td:nth-child(10),
.boq-main th:nth-child(1),
.boq-main th:nth-child(3),
.boq-main th:nth-child(4),
.boq-main th:nth-child(5),
.boq-main th:nth-child(6),
.boq-main th:nth-child(7),
.boq-main th:nth-child(8),
.boq-main th:nth-child(9),
.boq-main th:nth-child(10) {
  white-space: nowrap;
}

.boq-main td input,
.boq-main td select {
  min-height: 30px;
  padding: 4px 7px;
  min-width: 0;
}

.boq-main td textarea {
  min-height: 46px;
}

.boq-item-cell {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.boq-title-input {
  font-weight: 760;
}

.boq-description-field {
  min-width: 0;
  max-width: 100%;
  height: 46px;
  resize: vertical;
  line-height: 1.25;
}

.boq-inline-controls {
  grid-template-columns: minmax(0, 1fr) minmax(112px, 0.55fr);
}

.control-stack {
  display: grid;
  gap: 5px;
}

.smart-manual {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfa;
  padding: 10px;
}

.service-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  min-height: 0;
}

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metric-value {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 760;
}

.metric-note {
  margin-top: 4px;
  color: var(--soft-text);
  font-size: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.stat-row:last-child {
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  color: var(--soft-text);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  outline: none;
}

.form-grid .field:not(.full) input,
.form-grid .field:not(.full) select {
  max-width: none;
}

.user-row-form {
  display: grid;
  grid-template-columns: minmax(130px, 1.1fr) minmax(180px, 1.3fr) minmax(120px, 0.8fr) minmax(110px, 0.7fr) minmax(130px, 0.9fr) auto;
  gap: 8px;
  align-items: center;
}

.user-row-form input,
.user-row-form select {
  min-height: 34px;
}

textarea {
  min-height: 68px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(33, 122, 105, 0.14);
}

.btn {
  min-height: 36px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 12px;
  font-weight: 680;
  font-size: 13px;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.btn.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.btn.primary:hover {
  background: var(--brand-strong);
  color: #fff;
}

.btn.warn {
  border-color: #dfc386;
  background: #fff9e6;
  color: #6f4a00;
}

.btn.danger {
  border-color: #efb7b1;
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.icon {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
}

.btn.tertiary {
  border-color: transparent;
  background: transparent;
  color: var(--brand-strong);
}

.app-card-grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.dashboard-main {
  grid-column: span 1;
}

.donut-card {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.donut {
  width: 126px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--donut, conic-gradient(#d9e2de 0 100%));
  max-width: 100%;
}

.donut.empty {
  background: conic-gradient(#d9e2de 0 100%);
}

.donut-inner {
  width: 80px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  text-align: center;
  font-weight: 800;
  padding: 8px;
  min-width: 0;
}

.donut-inner div {
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.donut-inner small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.chart-legend {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.chart-row:last-child {
  border-bottom: 0;
}

.chart-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-row i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
}

.chart-row strong {
  white-space: nowrap;
}

.chart-empty {
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.muted-row {
  color: var(--muted);
}

.project-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.project-rail {
  display: grid;
  gap: 10px;
}

.project-search {
  margin-bottom: 10px;
}

.project-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 13px;
  text-align: left;
  display: grid;
  gap: 7px;
}

.project-card.active,
.project-card:hover {
  border-color: #9fd0c3;
  background: #f0faf6;
  box-shadow: inset 4px 0 0 var(--brand), var(--shadow-soft);
}

.project-card-top,
.project-card-meta,
.project-detail-head,
.summary-tile-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.project-detail-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.project-detail-title h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.project-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.project-form-sections {
  display: grid;
  gap: 10px;
}

.project-form-sections details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.project-form-sections summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 760;
}

.project-form-sections summary::-webkit-details-marker {
  display: none;
}

.project-form-section-body {
  border-top: 1px solid var(--line);
  padding: 14px;
}

.summary-tile-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.summary-tile {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 16px;
}

.survey-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(460px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.survey-section-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.survey-section-card summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
}

.survey-section-card summary::-webkit-details-marker {
  display: none;
}

.survey-card-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-weight: 800;
}

.survey-section-card .project-form-section-body {
  padding: 14px;
}

.doc-canvas {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #edf1ef;
  padding: 16px;
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.documents-workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.45fr) minmax(520px, 1fr);
  gap: 14px;
  align-items: start;
}

.document-edit-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.document-edit-card {
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.document-edit-card:last-child {
  border-bottom: 0;
}

.document-edit-card summary {
  cursor: pointer;
  list-style: none;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.document-edit-card summary::-webkit-details-marker {
  display: none;
}

.document-edit-card .field {
  padding: 0 12px 12px;
}

.document-toolbar {
  justify-content: space-between;
  margin-bottom: 12px;
}

.payment-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
  align-items: start;
}

.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.boq-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.boq-workspace.drawer-open {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
}

.boq-main {
  min-width: 0;
}

.boq-drawer {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 110px);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 33, 27, 0.1);
}

.drawer-header {
  align-items: center;
}

.drawer-body {
  max-height: calc(100vh - 178px);
  overflow: auto;
}

.boq-actions .btn {
  min-width: 0;
}

.drawer-body .form-grid,
.drawer-body .form-grid.three {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.drawer-body .field.full,
.drawer-body .btn.primary {
  grid-column: 1 / -1;
}

.drawer-body .btn.primary,
.form-grid > .btn,
.cost-modal-form > .btn,
.document-edit-list .btn {
  justify-self: start;
  width: auto;
}

.drawer-body input,
.drawer-body select,
.drawer-body textarea {
  max-width: none;
}

.inline-details summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
}

.inline-details summary strong {
  white-space: nowrap;
}

.ops-breakdown {
  margin-top: 8px;
  min-width: 0;
  background: #fff;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 7px 11px;
  color: var(--soft-text);
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--brand);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f7f6;
  color: #3c4c45;
  font-size: 12px;
  font-weight: 720;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.click-row {
  cursor: pointer;
}

.click-row:hover td,
.click-row.active td {
  background: #eef5f1;
}

.click-row.active td:first-child {
  box-shadow: inset 4px 0 0 var(--brand);
}

td input,
td select {
  min-width: 78px;
}

td.num,
th.num,
.col-money,
.col-qty,
.compact-table td,
.doc-boq .doc-qty,
.doc-boq .doc-price,
.doc-boq .doc-total,
.doc-total-row th,
.doc-total-row td {
  white-space: nowrap;
}

table input,
table select {
  max-width: 100%;
}

table textarea {
  min-width: 220px;
  min-height: 54px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  margin: 0;
}

td input[type="checkbox"] {
  min-width: 16px;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, 1.2fr);
  gap: 6px;
  margin: 6px 0;
}

.document-editor-panel {
  margin-bottom: 14px;
}

.document-editor-panel textarea {
  min-height: 78px;
  resize: vertical;
}

.document-editor-panel .panel-body {
  display: grid;
  gap: 10px;
}

.document-editor-panel .btn {
  justify-self: start;
}

.compact-table {
  min-width: 0;
}

.compact-table th,
.compact-table td {
  padding: 8px;
}

.compact-table th.num,
.compact-table td.num,
.compact-table .col-money,
.compact-table .col-qty {
  white-space: nowrap;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--soft-text);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.badge.ok {
  border-color: #aed8bd;
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  border-color: #dfc386;
  background: #fff9e6;
  color: #765200;
}

.badge.danger {
  border-color: #efb7b1;
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.accent {
  border-color: #e2b99f;
  background: var(--accent-soft);
  color: #81421e;
}

.list {
  display: grid;
  gap: 8px;
}

.list-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.title-line {
  font-weight: 800;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.warning-list {
  display: grid;
  gap: 8px;
}

.warning {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid #dfc386;
  border-radius: var(--radius);
  background: #fff9e6;
  padding: 10px;
}

.warning.high {
  border-color: #efb7b1;
  background: var(--danger-soft);
}

.warning.low {
  border-color: #bcd9c4;
  background: var(--ok-soft);
}

.project-picker {
  display: grid;
  grid-template-columns: minmax(240px, 420px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.project-picker .btn {
  justify-self: start;
  width: auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.tab {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--soft-text);
  min-width: 138px;
  padding: 9px 14px;
  font-weight: 750;
}

.tab.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.detail-window {
  overflow: hidden;
}

.compact-list table {
  min-width: 620px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  overflow: auto;
  background: rgba(17, 24, 22, 0.52);
  padding: 24px 14px;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(25, 39, 31, 0.24);
}

.modal-panel.modal-wide {
  width: min(1080px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 20px 22px;
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
}

.modal-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-body {
  padding: 20px 22px;
}

.modal-toolbar {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.modal-body .form-grid.three {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.modal-body .btn.primary[type="submit"] {
  grid-column: 1 / -1;
  justify-self: end;
  min-width: 140px;
  width: auto;
}

.logo-preview {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo-preview img {
  max-width: 150px;
  max-height: 64px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px;
}

.doc {
  width: min(190mm, 100%);
  min-height: 277mm;
  margin: 0 auto;
  border: 1px solid #e3e7e5;
  border-radius: 2px;
  background: #fff;
  padding: var(--doc-padding, 26px);
  color: #1b1f1d;
  font-size: var(--doc-font-size, 12px);
  font-family: var(--doc-font-family, Arial, sans-serif);
  line-height: var(--doc-line-height, 1.34);
  overflow-x: auto;
  box-shadow: 0 12px 28px rgba(15, 33, 27, 0.10);
}

.doc.compact-doc {
  padding: 20px 24px;
  font-size: 10.8px;
  line-height: 1.24;
}

.doc-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  border-bottom: 2px solid var(--doc-accent, #1f332e);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.doc-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 12px;
}

.doc-meta-grid > div {
  min-width: 0;
  overflow-wrap: anywhere;
}

.compact-table {
  font-size: 12.5px;
}

.compact-table th,
.compact-table td {
  vertical-align: top;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.profit-detail-table {
  min-width: 1180px;
}

td.num,
th.num,
.metric-value,
.doc-total-row th,
.doc-total-row td {
  white-space: nowrap;
}

.doc-brand {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.doc-brand img {
  max-width: 92px;
  max-height: 54px;
  object-fit: contain;
}

.doc h2,
.doc h3 {
  margin: 0 0 7px;
}

.doc h2 {
  font-size: 17px;
}

.doc h3 {
  font-size: 13px;
}

.doc-section {
  margin: 14px 0;
  break-inside: avoid;
}

.doc-fineprint {
  font-size: 0.82em;
  line-height: 1.25;
}

.doc-footer {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 8px;
  font-size: 0.78em;
  color: var(--muted);
}

.doc-fineprint ul {
  margin-top: 6px;
  padding-left: 18px;
}

.doc-fineprint li {
  margin: 2px 0;
}

.doc table {
  min-width: 0;
  table-layout: fixed;
}

.doc th {
  position: static;
}

.doc .num,
.compact-table .num,
td.num,
th.num {
  white-space: nowrap;
}

.doc-group-row td:first-child,
.doc-item-row td:first-child {
  color: var(--muted);
}

.doc-group-row td:nth-child(2),
.doc-item-row td:nth-child(2) {
  padding-left: 16px;
}

.doc th {
  position: static;
  background: #eef2ec;
}

.doc th,
.doc td {
  overflow-wrap: anywhere;
  padding: 5px 6px;
}

.doc .num,
.doc .col-money,
.doc .col-qty {
  white-space: nowrap;
  overflow-wrap: normal;
}

.doc-boq {
  width: 100%;
  table-layout: fixed;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.24;
}

.doc-boq .doc-no {
  width: 34px;
}

.doc-boq .doc-desc {
  width: auto;
}

.doc-boq .doc-qty {
  width: 58px;
}

.doc-boq .doc-price,
.doc-boq .doc-total {
  width: 92px;
}

.doc-boq td:first-child,
.doc-boq th:first-child {
  text-align: center;
}

.doc-boq td {
  word-break: normal;
  overflow-wrap: anywhere;
}

.doc-boq td.num,
.doc-boq th.num,
.doc-boq tfoot th,
.doc-boq tfoot td {
  overflow-wrap: normal;
  white-space: nowrap;
}

.doc-boq tbody td:nth-child(2) {
  white-space: normal;
  overflow-wrap: anywhere;
}

.doc-boq tfoot .totals-spacer {
  border-bottom: 0;
  background: transparent;
}

.doc-boq tfoot th {
  white-space: nowrap;
  text-align: right;
}

.doc-total-row th,
.doc-total-row td {
  font-size: 11px;
  background: #f4f7f5;
}

.doc-total-row.grand th,
.doc-total-row.grand td {
  background: #f4f7f5;
  font-weight: 800;
}

.proposal-doc .doc-section,
.rfq-doc .doc-section {
  margin: 10px 0;
}

.proposal-doc ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.proposal-doc li {
  margin: 2px 0;
}

.rfq-doc pre {
  margin: 8px 0;
  font-size: 11px;
  line-height: 1.25;
}

.report-print-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  break-inside: avoid;
}

.report-print-item p {
  margin: 6px 0 0;
}

.print-only {
  display: none;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel h1 {
  margin: 10px 0 6px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.quick-item {
  min-height: 74px;
  padding: 9px 10px;
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  overflow: hidden;
}

.quick-item small {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.76rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-master-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.product-master-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px;
  min-height: 86px;
  display: grid;
  gap: 5px;
}

.product-master-card strong {
  font-size: 0.88rem;
  line-height: 1.25;
}

.product-master-card .meta {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.next-action {
  margin-bottom: 14px;
}

.legacy-services {
  border-top: 1px solid var(--line);
  margin-top: 10px;
  padding-top: 10px;
}

.legacy-services summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
  padding: 8px 0;
}

.service-library-scroll {
  max-height: 74vh;
  overflow: auto;
  padding-right: 8px;
}

.service-row td {
  background: #fbfcfa;
}

input[readonly],
textarea[readonly] {
  background: #f6f8f5;
  color: var(--soft-text);
}

.template-card {
  min-height: 136px;
  display: grid;
  gap: 10px;
  align-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.template-card strong {
  display: block;
}

.mobile-top {
  display: none;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-shell.sidebar-collapsed .sidebar {
    display: none;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
  }

  .nav-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 6px;
  }

  .nav-label {
    grid-column: 1 / -1;
  }

  .grid.four,
  .grid.five,
  .grid.three,
  .grid.two,
  .grid.sidebar-layout,
  .boq-workspace.drawer-open,
  .dashboard-grid,
  .project-shell,
  .survey-workspace,
  .documents-workspace,
  .payment-layout,
  .summary-tile-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .boq-drawer {
    position: static;
    max-height: none;
  }

  .drawer-body {
    max-height: none;
  }

  .cost-guide {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
  }
}

@media (max-width: 1280px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-search {
    grid-column: 1 / -1;
    order: 3;
  }

  .toolbar {
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  .content,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

  .form-grid,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .project-picker,
  .doc-header {
    grid-template-columns: 1fr;
  }

  .doc-meta-grid {
    grid-template-columns: 1fr;
  }

  .doc {
    padding: 18px;
  }
}

@page {
  size: A4;
  margin: 12mm;
}

@media print {
  html,
  body {
    background: #fff !important;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .project-picker,
  .tabs,
  .no-print {
    display: none !important;
  }

  .app-shell,
  .main,
  .content {
    display: block;
    padding: 0;
    margin: 0;
  }

  .panel {
    border: 0;
    box-shadow: none;
  }

  .doc-canvas {
    border: 0;
    box-shadow: none;
    background: #fff !important;
    padding: 0;
  }

  .panel-header {
    display: none;
  }

  .doc {
    width: 100%;
    min-height: auto;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: #fff !important;
    font-size: 11.5px;
    overflow: visible;
  }

  .doc-header {
    grid-template-columns: minmax(0, 1fr) auto !important;
  }

  .doc-meta-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 16px;
  }

  .doc.compact-doc {
    font-size: 10.5px;
    line-height: 1.22;
  }

  .doc-section,
  .doc table,
  .compact-table {
    break-inside: avoid;
  }

  .print-only {
    display: block;
  }
}
