:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #65717d;
  --line: #d8e0e7;
  --accent: #177245;
  --accent-dark: #105937;
  --income: #1769aa;
  --warn: #b7791f;
  --danger: #b42318;
  --soft: #edf7f1;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 11px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f7;
}

.login-panel {
  width: min(380px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.12);
}

.login-panel h1 {
  margin: 0 0 20px;
  font-size: 1.35rem;
}

.login-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  font-weight: 700;
}

.login-panel input {
  width: 100%;
  border: 1px solid #c9d3df;
  border-radius: 6px;
  padding: 11px 12px;
}

.login-panel button {
  width: 100%;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.login-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-left: 4px solid var(--danger);
  background: #fff1f0;
  color: var(--danger);
}

.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.primary:hover { background: var(--accent-dark); }
.danger-button {
  background: #fff;
  color: var(--danger);
  border-color: #f3b4ae;
}
.danger-button:hover {
  background: #fee4e2;
  border-color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #172126;
  color: #fff;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  font-weight: 700;
}
.brand span {
  display: block;
  color: #b9c5cc;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 8px;
}
.nav-btn {
  text-align: left;
  background: transparent;
  color: #d8e0e7;
  border-color: transparent;
}
.nav-btn.active, .nav-btn:hover {
  background: #223038;
  color: #fff;
}

.content {
  padding: 24px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
h1, h2, h3 { margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { color: var(--muted); line-height: 1.45; }

.view { display: none; }
.view.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.kpi strong {
  font-size: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-head p {
  margin: 4px 0 0;
  font-size: 13px;
}
.section-total {
  display: grid;
  justify-items: end;
  gap: 2px;
}
.section-total span {
  color: var(--muted);
  font-size: 12px;
}
.section-total strong {
  font-size: 20px;
}
.split {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(360px, 1.2fr);
  gap: 16px;
}
.projects-split {
  grid-template-columns: minmax(520px, 1.25fr) minmax(360px, 0.75fr);
  align-items: start;
}
.project-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.project-toolbar p { margin: 4px 0 0; }
.hidden { display: none; }

.projects-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 14px;
}
.projects-hero h2 {
  font-size: 24px;
  margin: 2px 0 4px;
}
.projects-hero p {
  margin: 0;
  max-width: 720px;
}
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}
.hero-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 160px;
}
.mini-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.mini-kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.mini-kpi span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.mini-kpi strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}
.project-workspace {
  display: grid;
  grid-template-columns: minmax(560px, 1.35fr) minmax(360px, 0.75fr);
  gap: 16px;
  align-items: start;
}
.right-rail {
  display: grid;
  gap: 16px;
}
.project-list-panel {
  min-height: 560px;
}
.project-list-head {
  align-items: flex-start;
}
.search-input {
  width: 220px;
  min-width: 220px;
}
.compact-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.span-2 {
  grid-column: span 2;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 9px;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.amount, .num { text-align: right; font-variant-numeric: tabular-nums; }
.status {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 12px;
}
.status.Red { background: #fee4e2; color: var(--danger); }
.status.Yellow { background: #fff3cd; color: var(--warn); }
.income-text { color: var(--income); font-weight: 700; }
.expense-text { color: var(--danger); font-weight: 700; }
.remaining-text { color: var(--warn); font-weight: 700; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  color: var(--ink);
  background: #fff;
}
.field-error {
  border-color: var(--danger) !important;
  background: #fff5f5 !important;
}
textarea { min-height: 72px; resize: vertical; }
.form-grid button { align-self: end; }

.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
  overflow: hidden;
}
.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(16, 89, 55, 0.08);
}
.project-card strong { display: block; }
.project-card span { color: var(--muted); font-size: 13px; }
.project-card-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(104px, 0.7fr));
  gap: 0;
  align-items: center;
}
.project-card-grid > div {
  padding: 12px;
  min-height: 66px;
  border-left: 1px solid #eef2f5;
}
.project-card-grid > div:first-child {
  border-left: 0;
}
.project-card small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.project-card .metric-value {
  font-variant-numeric: tabular-nums;
}
.project-status-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--ink) !important;
  font-size: 12px !important;
  font-weight: 700;
}
.chart-stack {
  display: grid;
  gap: 14px;
}
.chart-block h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}
canvas {
  width: 100%;
  height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}
.charts-panel {
  position: sticky;
  top: 16px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.tight-actions {
  margin: 0;
  justify-content: flex-end;
}
.portfolio-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.project-detail-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.project-status-control {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  margin-bottom: 14px;
}
.project-status-control label {
  display: grid;
  gap: 6px;
  min-width: 190px;
  color: var(--muted);
  font-size: 12px;
}
.nested-section {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.nested-section h3 {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.project-top-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.project-finance-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(280px, 0.55fr);
  gap: 12px;
  align-items: stretch;
}
.expense-pie-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 100%;
}
.expense-pie-panel h3 {
  margin: 0;
  font-size: 15px;
}
.expense-pie-wrap {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.expense-pie {
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.expense-pie-legend {
  display: grid;
  gap: 7px;
}
.expense-pie-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  font-size: 12px;
}
.expense-pie-legend span {
  width: 10px;
  aspect-ratio: 1;
  border-radius: 50%;
}
.expense-pie-legend b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.expense-pie-legend em {
  color: var(--muted);
  font-style: normal;
}
.notice {
  border-left: 4px solid var(--warn);
  background: #fff8e6;
  padding: 12px;
  border-radius: 6px;
  margin: 12px 0;
}
.slim-notice {
  margin: 0;
  padding: 9px 11px;
  font-size: 13px;
}
.estimate-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.editor-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafb;
}
.editor-pill span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.editor-pill strong {
  font-size: 14px;
}
.back-button {
  align-self: flex-start;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.estimate-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.estimate-editor {
  min-width: 1120px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.estimate-editor th {
  background: #172126;
  color: #fff;
  border-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 1;
}
.estimate-editor td {
  padding: 5px;
}
.estimate-editor input,
.estimate-editor select,
.estimate-editor textarea {
  width: 100%;
  min-width: 0;
  padding: 6px;
  font-size: 11px;
  line-height: 1.25;
}
.estimate-editor th:nth-child(1) { width: 42px; }
.estimate-editor th:nth-child(2) { width: 190px; }
.estimate-editor th:nth-child(3) { width: 150px; }
.estimate-editor th:nth-child(4) { width: 135px; }
.estimate-editor th:nth-child(5) { width: 130px; }
.estimate-editor th:nth-child(6) { width: 62px; }
.estimate-editor th:nth-child(7) { width: 54px; }
.estimate-editor th:nth-child(8) { width: 82px; }
.estimate-editor th:nth-child(9) { width: 88px; }
.estimate-editor th:nth-child(10) { width: 180px; }
.estimate-editor th:nth-child(11) { width: 88px; }
.estimate-editor [data-field="comment"] {
  min-height: 46px;
  white-space: normal;
  overflow-wrap: anywhere;
  resize: vertical;
}
.estimate-editor [data-field="supplier_quote_ref"] {
  min-height: 46px;
}
.estimate-editor [data-field="supplier_quote_file"] {
  margin-top: 4px;
  font-size: 10px;
  padding: 5px;
}
.auto-item-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 28px;
  border-radius: 6px;
  background: #eef2f5;
  color: var(--muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.estimate-editor tfoot td {
  background: #f3f7f5;
  font-weight: 700;
}
.center { text-align: center; }
.include-delete-cell {
  text-align: center;
  white-space: nowrap;
}
.include-delete-cell input {
  width: auto;
  min-width: 0;
  vertical-align: middle;
  margin-right: 8px;
}
.icon-danger {
  color: var(--danger);
  border-color: #f3b4ae;
  padding: 6px 9px;
  font-weight: 700;
}
.muted-small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.estimate-page {
  width: 11in;
}
.estimate-lines {
  font-size: 12px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 24, 28, 0.58);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop.hidden {
  display: none;
}
.estimate-modal-window {
  width: min(1500px, 96vw);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(17, 24, 28, 0.28);
  padding: 16px;
}
.estimate-select-window {
  width: min(560px, 94vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(17, 24, 28, 0.28);
  padding: 16px;
}
.small-modal-window {
  width: min(420px, 94vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 70px rgba(17, 24, 28, 0.28);
  padding: 16px;
}
.expense-window {
  width: min(860px, 94vw);
}
.payment-window {
  width: min(760px, 94vw);
}
.invoice-window {
  width: min(820px, 94vw);
}
.project-window {
  width: min(820px, 94vw);
}
.quote-window {
  width: min(1080px, 96vw);
  max-height: 92vh;
  overflow: auto;
}
.change-order-window {
  width: min(820px, 94vw);
}
.expense-window input[readonly],
.expense-window select:disabled {
  background: #eef3f6;
  color: var(--ink);
  cursor: not-allowed;
}
.small-modal-window label {
  margin: 14px 0;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}
.checkbox-label input {
  width: auto;
}
.modal-actions-bottom {
  justify-content: flex-end;
  margin-top: 12px;
}
.estimate-select-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  max-height: 420px;
  overflow: auto;
}
.estimate-select-card {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 12px;
  border-radius: 8px;
}
.estimate-select-card strong,
.estimate-select-card span {
  display: block;
}
.estimate-select-card span {
  color: var(--muted);
  font-size: 13px;
}
.quote-estimate-list {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  max-height: 170px;
  overflow: auto;
  background: #fbfcfd;
}
.quote-estimate-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.quote-estimate-option input {
  width: auto;
}
.quote-estimate-option strong,
.quote-estimate-option span {
  display: block;
}
.quote-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.quote-editor {
  min-width: 720px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.quote-editor th {
  background: #172126;
  color: #fff;
}
.quote-editor td {
  padding: 6px;
}
.quote-editor input {
  width: 100%;
  min-width: 0;
}
.quote-editor th:nth-child(1) { width: 32%; }
.quote-editor th:nth-child(2) { width: 28%; }
.quote-editor th:nth-child(3) { width: 16%; }
.quote-editor th:nth-child(4) { width: 16%; }
.quote-editor th:nth-child(5) { width: 8%; }
.quote-editor tfoot td {
  background: #f3f7f5;
  font-weight: 800;
}
.status-button-row {
  display: flex;
  gap: 6px;
  align-items: end;
  flex-wrap: wrap;
}
.status-button-row button {
  padding: 8px 10px;
}
.settings-logo-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
.settings-logo-preview img {
  max-width: 120px;
  max-height: 70px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.report-block {
  margin-top: 18px;
}
.report-block h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}
.report-card-grid {
  display: grid;
  gap: 18px;
  margin: 14px 0 18px;
}
.report-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.report-section > h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}
.report-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.report-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}
.report-card p {
  min-height: 42px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}
.report-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.report-card-actions button {
  padding: 8px 10px;
}
.report-format-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 12px;
}
.report-format-actions label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.report-format-actions button {
  min-height: 42px;
}
.report-format-actions button:nth-of-type(1) {
  grid-column: span 2;
}
.report-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 12px;
}
.report-checkbox-option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}
.report-generated h3 {
  margin-top: 16px;
}
.report-empty-state {
  color: var(--muted);
}
.full-width {
  width: 100%;
}
.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}
.validation-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.validation-list li {
  border-left: 4px solid var(--danger);
  background: #fff5f5;
  color: var(--danger);
  border-radius: 6px;
  padding: 9px 10px;
}
.info-modal .validation-list li {
  border-left-color: var(--accent);
  background: #eefbf3;
  color: var(--ink);
}
.saved-toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 180;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 18px 28px;
  text-align: center;
  box-shadow: 0 16px 45px rgba(17, 24, 28, 0.22);
  min-width: 190px;
}
.saved-toast small {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}
.saved-toast strong {
  display: block;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}
.modal-title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-close-button {
  margin-left: auto;
  align-self: flex-start;
}
.saved-stamp {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
  align-self: center;
}
.estimate-meta-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 150px minmax(220px, auto) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.estimate-meta-grid input[readonly] {
  background: #eef3f6;
}
.panel-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 10px;
}
.panel-heading-row h2 {
  margin: 0;
}
.panel-total {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}
.estimate-summary-grid {
  display: grid;
  gap: 14px;
}
.estimate-summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.estimate-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px;
  background: #f5f8fa;
  border-bottom: 1px solid var(--line);
}
.estimate-summary-head strong,
.estimate-summary-head span {
  display: block;
}
.estimate-summary-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.modal-titlebar > div {
  flex: 1;
}
.modal-titlebar p {
  margin: 4px 0 0;
}
.modal-table-wrap {
  flex: 1;
  min-height: 0;
}
pre {
  white-space: pre-wrap;
  background: #11181c;
  color: #d8e0e7;
  padding: 12px;
  border-radius: 8px;
}

.quote-print {
  background: #e9eef2;
}
.quote-page {
  width: 8.5in;
  min-height: 11in;
  margin: 24px auto;
  padding: 0.55in;
  background: white;
  border: 1px solid #ccd6dd;
}
.quote-header {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.quote-company-block {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.quote-logo {
  width: 105px;
  max-height: 75px;
  object-fit: contain;
}
.quote-logo-placeholder {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  background: #172126;
  color: #fff;
  font-size: 34px;
  font-weight: 800;
}
.quote-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: right;
}
.quote-title span,
.quote-title b {
  display: block;
}
.quote-title b {
  font-size: 15px;
  margin-top: 8px;
}
.quote-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.quote-lines th {
  background: #172126;
  color: white;
}
.quote-totals {
  width: 320px;
  margin-left: auto;
  text-align: right;
}
.signature {
  margin-top: 38px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .kpi-grid, .split, .detail-grid, .mini-kpi-grid, .project-workspace, .project-top-kpis, .project-finance-layout, .expense-pie-wrap { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .projects-hero, .project-list-head { align-items: stretch; flex-direction: column; }
  .estimate-toolbar { grid-template-columns: 1fr; }
  .search-input { width: 100%; min-width: 0; }
  .project-card-grid { grid-template-columns: 1fr 1fr; }
  .project-card-grid > div:first-child { grid-column: span 2; }
  .charts-panel { position: static; }
}

@media print {
  body.quote-print { background: white; }
  .quote-page {
    margin: 0;
    border: 0;
    width: auto;
    min-height: auto;
  }
}
