:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #172127;
  --muted: #66747b;
  --line: #dce4e1;
  --brand: #173f46;
  --brand-strong: #0f3036;
  --accent: #2f7668;
  --accent-soft: #e7f3ef;
  --danger: #b42318;
  --warning: #9a6700;
  --ok: #18794e;
  --shadow: 0 14px 34px rgba(23, 33, 39, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Arial, Helvetica, sans-serif;
}

a { color: var(--brand); font-weight: 700; text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--muted); }
hr { border: 0; border-top: 1px solid rgba(255,255,255,.16); margin: 16px 0; }
.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 6px;
  background: #fff;
  color: var(--brand);
  box-shadow: var(--shadow);
}
.skip-link:focus { transform: translateY(0); }

.guest {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, #dbece7, transparent 34%), #f5f7f6;
}
.auth-card {
  width: min(780px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 20px; color: var(--brand); font-size: 26px; }

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}
.nav-toggle { display: none; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  padding: 20px;
  background: #102f36;
  color: #fff;
}
.sidebar-backdrop,
.sidebar-close,
.mobile-menu-button,
.mobile-tabbar { display: none; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  padding: 4px 2px 14px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e4f2ee;
  color: var(--brand);
  font-weight: 900;
}
.brand-logo { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 8px; }
.brand-logo.brand-wordmark { width: 218px; height: auto; max-width: 100%; border-radius: 0; object-fit: contain; object-position: left center; }
.brand strong { display: block; font-size: 20px; letter-spacing: 0; }
.brand small { display: block; color: #a9c5c9; font-size: 12px; font-weight: 700; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar-search {
  display: grid;
  gap: 6px;
  padding: 0 2px 4px;
}
.sidebar-search label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #b6ced0;
  font-size: 11px;
  font-weight: 800;
}
.sidebar-search kbd {
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px;
  color: #dce9e9;
  font: inherit;
  font-size: 10px;
}
.sidebar-search input {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 14px;
}
.sidebar-search input::placeholder { color: #a8c4c6; }
.sidebar-search input:focus { outline-color: #b5f2dc; border-color: #b5f2dc; }
.sidebar-search-clear {
  justify-self: start;
  min-height: 26px;
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: #b5f2dc;
  font-size: 11px;
  font-weight: 800;
}
.sidebar-search-status {
  color: #b6ced0;
  font-size: 11px;
}
.nav-group {
  margin: 14px 10px 6px;
  color: #9fc0c6;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.sidebar a,
.link-button {
  width: 100%;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #eef7f7;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}
.sidebar a:hover,
.sidebar a.active,
.link-button:hover {
  background: rgba(255,255,255,.12);
  text-decoration: none;
}
.context-label {
  display: block;
  margin: 0 10px 4px;
  color: #fff;
  font-weight: 800;
}
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.16);
}

.content { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 32px;
  background: rgba(244,246,245,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar strong { display: block; }
.topbar span { color: var(--muted); font-size: 13px; }
.tenant-pill {
  max-width: 52ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #b7d7cf;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 13px;
}
.workspace {
  width: min(1440px, 100%);
  padding: 28px 32px 46px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.page-head p { margin: 6px 0 0; }
.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
}
h1, h2, h3 { letter-spacing: 0; }
h1 { margin: 0; font-size: 31px; line-height: 1.12; }
h2 { margin: 0 0 14px; font-size: 19px; }
h3 { margin: 18px 0 8px; font-size: 16px; }
.muted { color: var(--muted); }

.actions,
.section-head,
.inline-form,
.search {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.section-head { justify-content: space-between; margin-bottom: 12px; }
.section-head.padded { padding: 16px 18px 0; }
.actions form { margin: 0; }
.search { margin-bottom: 16px; }

.panel,
.print-document {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.panel.flush { padding: 0; overflow: hidden; }
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metrics div {
  position: relative;
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.metrics div::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  opacity: .75;
}
.metrics span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.metrics strong { display: block; margin-top: 8px; font-size: 27px; line-height: 1.15; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.stack { display: grid; gap: 12px; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.report-editor-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.report-editor .section-head {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}
.report-editor textarea {
  min-height: 132px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.billing-notice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 0 0 18px;
  padding: 16px 18px;
  border: 1px solid #b8d8cf;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #f3faf7;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.billing-notice.danger-zone {
  border-color: #efc0bd;
  border-left-color: var(--danger);
  background: #fff6f5;
}
.billing-notice strong {
  display: block;
  color: var(--brand);
  font-size: 18px;
}
.billing-notice p {
  margin: 4px 0 0;
  color: var(--muted);
}
.billing-notice > div:last-child {
  display: grid;
  gap: 4px;
  min-width: 190px;
  text-align: right;
}
.billing-notice > div:last-child span,
.billing-notice small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}
.project-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.project-card h2 {
  margin: 4px 0;
}
.project-card p {
  margin: 0;
  color: var(--muted);
}
.project-page {
  display: grid;
  gap: 18px;
}
.project-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.project-titlebar p {
  margin: 6px 0 0;
  color: var(--muted);
}
.project-subnav {
  position: sticky;
  top: 64px;
  z-index: 8;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(8px);
}
.project-subnav a {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.project-subnav a:hover {
  background: #eef4f2;
  color: var(--brand);
  text-decoration: none;
}
.project-command {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(0, 2.2fr);
  gap: 12px;
  align-items: stretch;
}
.command-primary,
.command-metrics > div,
.cost-summary-strip > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.command-primary {
  display: grid;
  align-content: center;
  background: #f8fbfa;
}
.command-primary strong {
  display: block;
  font-size: 32px;
  line-height: 1.08;
}
.command-primary small,
.command-metrics small {
  color: var(--muted);
}
.command-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.command-metrics span,
.cost-summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.command-metrics strong,
.cost-summary-strip strong {
  display: block;
  margin: 5px 0 2px;
  color: var(--brand);
  font-size: 20px;
  line-height: 1.1;
}
.project-section-clean {
  gap: 16px;
}
.compact-form {
  grid-template-columns: 180px 180px minmax(240px, 1fr) auto;
  align-items: end;
}
.cost-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.compact-alerts {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.project-workspace-grid,
.cashflow-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 16px;
  align-items: start;
}
.project-table-block,
.project-list-block,
.project-side-stack > div,
.cashflow-column {
  min-width: 0;
  display: grid;
  gap: 10px;
}
.project-side-stack {
  display: grid;
  gap: 16px;
}
.dense-list article {
  padding: 10px 12px;
}
.dense-list .row-actions button,
.dense-list .row-actions a {
  min-height: 30px;
  padding: 5px 9px;
}
.project-kpis,
.project-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.project-kpis div,
.project-hero > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.project-kpis span,
.project-hero span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.project-kpis strong,
.project-hero strong {
  display: block;
  margin-top: 6px;
  color: var(--brand);
  font-size: 20px;
}
.project-hero {
  margin-bottom: 18px;
}
.project-hero > div {
  background: var(--surface);
  padding: 18px;
}
.project-hero strong {
  font-size: 28px;
}
.project-hero p {
  margin: 6px 0 0;
  color: var(--muted);
}
.project-entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}
.composer-panel {
  margin: 0 0 16px;
  padding: 16px;
  background: #f6f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.composer-panel .project-entry-form,
.composer-panel .room-composer,
.composer-panel .room-photo-upload,
.composer-panel .photo-edit-form,
.composer-panel .estimate-item-entry {
  padding: 0;
  margin-bottom: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.room-photo-toggle {
  margin-top: 12px;
}
.project-sections {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  gap: 18px;
  align-items: start;
}
.project-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.project-cashflow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}
.project-section {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 0 rgba(23,33,39,.03), 0 8px 24px rgba(16,47,54,.04);
  scroll-margin-top: 24px;
}
.project-section-summary {
  min-height: 100%;
}
.project-section-primary {
  grid-row: span 2;
}
.project-section .section-head {
  margin-bottom: 0;
}
.project-section .section-head h2 {
  margin-bottom: 4px;
}
.project-section .section-head p {
  max-width: 68ch;
  margin: 0;
}
.project-section .composer-panel {
  margin-bottom: 0;
}
.project-section .empty-state.compact {
  padding: 14px 16px;
}
.project-report {
  margin-bottom: 18px;
}
.finance-bars {
  display: grid;
  gap: 14px;
}
.finance-bars.compact {
  gap: 10px;
}
.finance-bars span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.finance-bars small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}
.bar {
  height: 12px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7efec;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.bar i.tone-brand { background: var(--brand); }
.bar i.tone-ok { background: var(--ok); }
.bar i.tone-warning { background: var(--warning); }
.bar.danger i {
  background: var(--danger);
}
.text-success { color: var(--ok); }
.text-warning { color: var(--warning); }
.cost-control-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.cost-control-kpis div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.cost-control-kpis span,
.mini-section-head small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.cost-control-kpis strong {
  display: block;
  margin: 5px 0 2px;
  color: var(--brand);
  font-size: 21px;
  line-height: 1.1;
}
.cost-control-kpis small {
  display: block;
  color: var(--muted);
}
.cost-alerts {
  display: grid;
  gap: 8px;
}
.cost-alert {
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef4f2;
  color: var(--brand);
  font-weight: 800;
}
.cost-alert.warning {
  background: #fff4d6;
  color: var(--warning);
}
.cost-alert.danger {
  background: #fdecea;
  color: var(--danger);
}
.cost-control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  gap: 14px;
}
.cost-control-block {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}
.mini-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.mini-section-head strong {
  font-size: 15px;
}
.cost-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.cost-control-table {
  box-shadow: none;
}
.cost-control-table td strong,
.cost-control-table td small {
  display: block;
}
.mini-bar {
  width: 100%;
  min-width: 82px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7efec;
}
.mini-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.rank-list {
  display: grid;
  gap: 8px;
}
.rank-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.rank-list.compact article {
  padding: 10px 0;
  border-width: 0 0 1px;
  border-radius: 0;
}
.rank-list article strong,
.rank-list article small {
  display: block;
}
.rank-list article small {
  margin: 2px 0 7px;
  color: var(--muted);
}
.rank-list article b {
  color: var(--brand);
  white-space: nowrap;
}
.project-page {
  display: grid;
  gap: 18px;
}
.project-page .project-titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 4px;
}
.project-page .project-titlebar p {
  margin: 6px 0 0;
  color: var(--muted);
}
.project-subnav {
  position: static;
  z-index: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  backdrop-filter: none;
}
.project-subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand);
  font-size: 13px;
}
.project-command,
.command-metrics,
.cost-summary-strip,
.project-workspace-grid,
.cashflow-grid {
  display: grid;
  gap: 12px;
}
.project-command,
.project-workspace-grid,
.cashflow-grid {
  grid-template-columns: 1fr;
}
.command-metrics,
.cost-summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.command-primary,
.command-metrics > div,
.cost-summary-strip > div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.command-primary strong {
  display: block;
  color: var(--brand);
  font-size: 26px;
  line-height: 1.12;
}
.command-primary small,
.command-metrics small {
  display: block;
  color: var(--muted);
}
.command-metrics span,
.cost-summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.command-metrics strong,
.cost-summary-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--brand);
  font-size: 19px;
}
.project-section-clean {
  display: grid;
  gap: 14px;
}
.compact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.compact-form .form-actions {
  align-self: end;
}
.project-table-block,
.project-list-block,
.project-side-stack,
.project-side-stack > div,
.cashflow-column {
  min-width: 0;
  display: grid;
  gap: 10px;
}
.project-side-stack {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}
.dense-list article {
  padding: 10px 12px;
}
.simple-list {
  display: grid;
  gap: 10px;
}
.simple-list article {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.row-actions form {
  margin: 0;
}
.row-actions button,
.row-actions a {
  min-height: 34px;
  padding: 6px 10px;
}
.simple-list small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}
.supplier-quote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.linked-suppliers {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.linked-suppliers > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.badge.neutral {
  background: #eaf1ef;
  color: var(--brand);
}
.supplier-quote-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.supplier-quote-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.supplier-quote-card-head h3 {
  margin: 0 0 6px;
}
.supplier-quote-card-head p {
  margin: 0;
  color: var(--muted);
}
.supplier-quote-card-head > strong {
  color: var(--brand);
  font-size: 22px;
  white-space: nowrap;
}
.supplier-quote-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.supplier-quote-facts span {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f9f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.supplier-quote-facts b {
  color: var(--brand);
}
.contract-callout {
  display: grid;
  gap: 10px;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid #b8d8cf;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: #f3faf7;
}
.text-danger {
  color: var(--danger) !important;
}
.full { grid-column: 1 / -1; }

label { display: grid; gap: 6px; color: #26363d; font-weight: 850; }
.cep-lookup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.cep-lookup small {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
  font-weight: 800;
}
.cep-lookup small[data-type="success"] { color: var(--ok); }
.cep-lookup small[data-type="error"] { color: var(--danger); }
input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cbd7d3;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
textarea { min-height: 98px; resize: vertical; }
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(47,118,104,.16);
  border-color: var(--accent);
}
input,
select,
textarea,
button,
.button,
a,
.mobile-menu-button,
.sidebar-close,
.link-button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgba(46,118,104,.28);
  outline-offset: 2px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
}
button:hover,
.button:hover { background: var(--brand-strong); text-decoration: none; }
.button.secondary,
button.secondary,
table button {
  background: #eef4f2;
  border-color: var(--line);
  color: var(--brand);
}
.button.secondary:hover,
button.secondary:hover,
table button:hover { background: #e3ece9; }
.danger { background: var(--danger); color: #fff; }
.danger:hover { background: #8f1d15; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(16, 47, 54, .04);
}
th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
th {
  background: #f0f5f3;
  color: #4b5c63;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
tbody tr:hover td { background: #fbfdfc; }

.alert {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 6px;
  font-weight: 800;
}
.success { background: #e7f5ee; color: var(--ok); border: 1px solid #c5e6d6; }
.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c1; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf2f1;
  color: #405258;
  font-size: 12px;
  font-weight: 850;
}
.badge.active,
.badge.approved,
.badge.finished,
.badge.finalized,
.badge.success,
.badge.sent { background: #e5f5ed; color: var(--ok); }
.badge.pending,
.badge.pending_supplier,
.badge.pending_client,
.badge.draft,
.badge.review,
.badge.in_progress { background: #fff4d6; color: var(--warning); }
.badge.suspended,
.badge.rejected,
.badge.failed,
.badge.inactive,
.badge.cancelled { background: #fdecea; color: var(--danger); }

.empty-state {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 160px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed #c8d6d2;
  border-radius: 8px;
}
.empty-state strong { color: var(--ink); font-size: 17px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.gallery img { width: 100%; height: 136px; object-fit: cover; border-radius: 6px; }
.gallery figcaption { margin-top: 7px; color: var(--muted); font-size: 13px; }

.budget-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}
.budget-summary {
  position: sticky;
  top: 84px;
}
.clean-form,
.budget-data-form {
  border: 0;
  padding: 0;
}
.budget-data-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.summary-line,
.summary-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.summary-line span,
.summary-total span { color: var(--muted); font-weight: 800; }
.summary-total {
  margin: 8px 0 16px;
  border-bottom: 0;
  font-size: 18px;
}
.summary-total strong { font-size: 24px; color: var(--brand); }
.wide { width: 100%; }
.item-composer,
.room-composer {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(110px, .8fr) minmax(90px, .6fr) minmax(110px, .7fr);
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.item-composer .span-2 { grid-column: span 2; }
.item-composer button,
.room-composer button { align-self: end; }
.item-composer button { min-width: 150px; }
.budget-items-table td:nth-child(2) { min-width: 280px; }

.estimate-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 300px);
  gap: 18px;
  align-items: start;
}
.estimate-sheet {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.estimate-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 18px;
  align-items: end;
  padding: 18px;
  background: #f6f9f8;
  border-bottom: 1px solid var(--line);
}
.estimate-status-box {
  display: grid;
  gap: 4px;
  justify-items: end;
}
.estimate-status-box strong {
  color: var(--brand);
  font-size: 26px;
}
.estimate-block {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.estimate-block:last-child { border-bottom: 0; }
.estimate-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.estimate-textareas {
  display: grid;
  gap: 14px;
}
.estimate-savebar {
  display: flex;
  justify-content: flex-end;
  padding: 14px 18px;
  background: #fbfcfc;
}
.estimate-summary {
  min-width: 0;
  position: sticky;
  top: 82px;
}
.estimate-summary-card {
  display: grid;
  gap: 0;
  padding: 18px;
  background: #102f36;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.estimate-summary-card .eyebrow { color: #a8c8cc; }
.estimate-summary-card > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.estimate-summary-card span { color: #c9dde0; font-weight: 800; }
.estimate-grand-total strong { font-size: 24px; }
.estimate-summary-card .button { margin-top: 16px; }
.finance-summary-card {
  margin-top: 16px;
  background: linear-gradient(180deg, #13424a 0%, #102f36 100%);
}
.finance-summary-card small {
  display: block;
  padding-top: 10px;
  color: #d4e7e9;
  font-weight: 700;
  line-height: 1.4;
}
.estimate-item-entry {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 90px 80px 90px 120px 100px;
  gap: 10px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  background: #f6f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.estimate-item-entry .item-entry-notes {
  grid-column: 1 / -2;
}
.inline-feedback {
  min-height: 22px;
  margin: -6px 0 14px;
  color: #315f49;
  font-size: 13px;
  font-weight: 800;
}
.inline-feedback[data-type="error"] {
  color: #9f2f2f;
}
.estimate-items {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.estimate-items-head,
.estimate-item-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 72px 110px 90px 110px 96px;
  gap: 10px;
  align-items: center;
  min-width: 760px;
  padding: 12px 14px;
}
.estimate-items-head {
  background: #eef4f2;
  color: #4b5c63;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.estimate-item-row {
  border-top: 1px solid var(--line);
  background: #fff;
}
.estimate-item-row small,
.estimate-item-row strong { display: block; }
.estimate-item-row b { color: var(--brand); }
.is-hidden { display: none !important; }
button:disabled {
  cursor: wait;
  opacity: .68;
}

.budget-page-head,
.budget-studio,
.budget-canvas,
.budget-head-actions,
.proposal-form,
.line-items-list {
  display: grid;
  gap: 16px;
}
.budget-page-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  margin-bottom: 20px;
}
.budget-head-actions {
  grid-auto-flow: column;
  align-items: center;
  gap: 10px;
}
.budget-studio {
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
}
.budget-canvas {
  gap: 18px;
}
.proposal-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}
.proposal-card-number {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
}
.proposal-card-body {
  min-width: 0;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.proposal-card textarea {
  min-height: 122px;
}
.proposal-inline-footer {
  display: grid;
  grid-template-columns: minmax(180px, 240px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.proposal-sidebar {
  position: sticky;
  top: 82px;
}
.proposal-preview-card {
  background: #102f36;
  color: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.proposal-preview-card .eyebrow,
.proposal-preview-card .muted {
  color: #a9cbd0;
}
.proposal-preview-card h2 {
  color: #fff;
  margin-bottom: 4px;
}
.proposal-total-stack {
  display: grid;
  gap: 0;
  margin: 18px 0;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  overflow: hidden;
}
.proposal-total-stack div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}
.proposal-total-stack div:last-child {
  border-bottom: 0;
}
.proposal-total-stack span {
  color: #c8dde0;
  font-weight: 800;
}
.proposal-total-stack .total {
  background: rgba(255,255,255,.12);
}
.proposal-total-stack .total strong {
  font-size: 22px;
}
.line-item-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  margin-bottom: 18px;
  background: #f5f8f7;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.line-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 12px;
}
.line-numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.line-item-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.line-item-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #edf4f2;
  color: var(--brand);
  font-weight: 900;
}
.line-item-content {
  min-width: 0;
}
.line-item-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}
.line-item-title strong,
.line-item-title small {
  display: block;
}
.line-item-title b {
  color: var(--brand);
  white-space: nowrap;
}
.line-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.line-item-meta span {
  border-radius: 999px;
  background: #f0f5f3;
  color: #52636b;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.print-toolbar {
  max-width: 210mm;
  margin: 20px auto 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.print-page {
  background: #e8eceb;
}
.print-page .print-toolbar {
  padding: 0 12px;
}
.proposal-document {
  width: 210mm;
  max-width: calc(100vw - 24px);
  min-height: 297mm;
  margin: 18px auto 36px;
  padding: 18mm;
  background: #fff;
  color: #1b252b;
  border: 1px solid #d7d7d7;
  box-shadow: var(--shadow);
}

.budget-print-page .proposal-header {
  border-bottom: 4px solid var(--brand);
}

.budget-print-page .proposal-section,
.budget-print-page .proposal-grid > div,
.budget-print-page .proposal-bottom > div,
.budget-print-page .proposal-total-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.budget-print-page .proposal-section,
.budget-print-page .proposal-grid > div {
  padding: 16px;
}

.budget-print-page .proposal-grid {
  gap: 16px;
}

.budget-print-page .proposal-bottom {
  gap: 18px;
}

.budget-print-page .proposal-items {
  width: 100%;
  border-collapse: collapse;
}

.budget-print-page .proposal-items th,
.budget-print-page .proposal-items td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.budget-print-page .proposal-items thead th {
  background: #eef4f2;
  color: #4b5c63;
}

.budget-print-page .proposal-items tbody tr:nth-child(even) td {
  background: #fbfcfc;
}

.contract-document .proposal-header {
  border-bottom-width: 3px;
}

.contract-document .proposal-section,
.contract-document .proposal-grid > div,
.contract-document .proposal-bottom > div,
.contract-document .proposal-total-box {
  border-radius: var(--radius-lg);
}

.contract-document .proposal-section,
.contract-document .proposal-grid > div,
.contract-document .proposal-total-box {
  border: 1px solid #dbe3e0;
  background: #fff;
}

.contract-document .proposal-section {
  padding: 16px;
}

.contract-document .proposal-grid > div {
  padding: 16px;
}

.contract-document .proposal-items {
  width: 100%;
  border-collapse: collapse;
}

.contract-document .proposal-items th,
.contract-document .proposal-items td {
  padding: 10px 12px;
}

/* UI refresh overrides */
body {
  background:
    radial-gradient(circle at top left, rgba(46,118,104,.10), transparent 32%),
    radial-gradient(circle at top right, rgba(18,55,62,.08), transparent 28%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  grid-template-columns: 280px minmax(0, 1fr);
}

.nav-toggle {
  display: none;
}

.panel,
.metrics div,
.grid-form,
.project-card,
.project-kpis div,
.project-hero > div,
.supplier-quote-card,
.contract-callout,
.auth-card,
.auth-brand,
.empty-state,
.billing-notice,
.proposal-card,
.proposal-preview-card,
.line-item-card,
.estimate-summary-card,
.table,
table,
.tabs {
  border-radius: 16px;
}

.sidebar {
  box-shadow: 18px 0 42px rgba(9, 19, 22, .18);
}

.brand-mark {
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}

.topbar {
  background: rgba(238,242,241,.86);
  backdrop-filter: blur(14px);
}

.topbar-user {
  display: grid;
  gap: 2px;
}

.mobile-menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font-weight: 900;
}

.sidebar-backdrop,
.sidebar-close {
  display: none;
}

.button,
button {
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
}

table {
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(16, 47, 54, .04);
}

th {
  background: #eff5f3;
}

tbody tr:nth-child(even) td {
  background: #fcfdfd;
}

.search {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search input {
  min-width: min(360px, 100%);
  flex: 1 1 220px;
}

.search button {
  flex: 0 0 auto;
}

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

.critical-actions .danger,
.critical-actions button.danger {
  box-shadow: 0 10px 18px rgba(180,35,24,.16);
}

.critical-actions .danger:hover,
.critical-actions button.danger:hover {
  transform: translateY(-1px);
}

.form-page {
  display: grid;
  gap: 18px;
}

.form-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 0 rgba(23,33,39,.03), 0 8px 24px rgba(16,47,54,.04);
}

.form-section .section-head {
  margin-bottom: 0;
}

.compact-grid {
  gap: 12px;
}

.form-page .form-actions {
  justify-content: flex-end;
}

.table-card {
  width: 100%;
}

.page-head,
.section-head,
.billing-notice,
.project-card-head,
.supplier-quote-card-head,
.line-item-title {
  gap: 14px;
}

.page-head p,
.section-head p,
.project-card p,
.supplier-quote-card p,
.empty-state span,
.auth-brand p {
  color: var(--muted);
}

.metrics strong {
  color: var(--brand);
}

.alert {
  border-radius: 12px;
}

.success {
  background: #e7f5ee;
  color: var(--ok);
}

.error {
  background: #fdecea;
  color: var(--danger);
}

.empty-state {
  background: linear-gradient(180deg, #fff, #fafcfc);
  border-style: dashed;
}

.mobile-tabbar {
  display: none;
}

.guest {
  background:
    radial-gradient(circle at top left, rgba(46,118,104,.12), transparent 34%),
    radial-gradient(circle at bottom right, rgba(18,55,62,.10), transparent 30%),
    var(--bg);
}

.auth-shell {
  width: min(820px, 100%);
  display: block;
}

.auth-brand {
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 32px;
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(160deg, #10343b, #0d252a);
  border: 1px solid rgba(183,234,216,.18);
  box-shadow: var(--shadow);
}

.auth-brand::after {
  content: "";
  position: absolute;
  width: 240px;
  height: 240px;
  right: -92px;
  bottom: -112px;
  border: 1px solid rgba(255,158,87,.38);
  border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(255,158,87,.06), 0 0 0 44px rgba(183,234,216,.04);
}

.auth-brand h1 {
  margin: 0;
  max-width: 520px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.02;
  letter-spacing: -.04em;
}

.auth-brand p {
  max-width: 500px;
  margin: 0;
  color: #c2d8d5;
  font-size: 16px;
}

.auth-eyebrow {
  color: #b7ead8;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.auth-brand-points {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 8px 0 0;
  list-style: none;
  color: #eef8f5;
  font-size: 14px;
  font-weight: 700;
}
.auth-brand-points li { display: flex; align-items: center; gap: 9px; }
.auth-brand-points li span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #b7ead8;
  color: #10343b;
  font-size: 12px;
  font-weight: 900;
}

.auth-brand .brand-mark {
  width: 52px;
  height: 52px;
}
.guest-brand-logo { width: 58px; height: 58px; border-radius: 16px; }.guest-brand-logo.guest-wordmark { width: min(300px, 100%); height: auto; padding: 10px 14px; border-radius: 12px; background: #f5fbf8; }

.auth-card-brand { display: grid; justify-items: center; gap: 10px; margin: -4px 0 26px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.auth-card-brand .auth-eyebrow { color: var(--accent); }

.auth-card {
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(18,55,62,.12);
  box-shadow: 0 20px 55px rgba(16,47,54,.12);
}
.auth-card h2 { color: var(--brand); letter-spacing: -.02em; }
.auth-card > p { color: var(--muted); }
.auth-card-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.auth-card-footer a { color: var(--accent); }
.auth-card button[type="submit"] {
  background: #ff9e57;
  border-color: #ff9e57;
  color: #17343a;
  box-shadow: 0 10px 22px rgba(255,158,87,.22);
}
.auth-card button[type="submit"]:hover { background: #f18b43; border-color: #f18b43; }

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

  .mobile-menu-button {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 320px);
    transform: translateX(-102%);
    z-index: 40;
    transition: transform .24s ease;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    border: 0;
    background: rgba(7, 15, 17, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-close {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 8px;
    background: rgba(255,255,255,.12);
  }

  .mobile-tabbar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(10px);
  }

  .mobile-tabbar a {
    min-height: 42px;
    padding: 8px 6px;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    font-size: 12px;
  }

  .mobile-tabbar a.active {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .columns,
  .budget-builder,
  .estimate-editor,
  .budget-studio,
  .proposal-header,
  .auth-shell,
  .project-grid,
  .project-kpis,
  .project-command,
  .command-metrics,
  .cost-summary-strip,
  .project-workspace-grid,
  .cashflow-grid,
  .project-board,
  .project-hero,
  .project-cashflow,
  .project-sections,
  .cost-control-grid,
  .supplier-quote-grid {
    grid-template-columns: 1fr;
  }
  .cost-control-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .project-section-primary {
    grid-row: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-backdrop,
  .sidebar-collapse-icon,
  .content {
    transition: none !important;
  }
}

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

  .page-head,
  .project-titlebar,
  .section-head,
  .billing-notice,
  .project-card-head,
  .supplier-quote-card-head,
  .mini-section-head,
  .line-item-title,
  .form-actions,
  .row-actions,
  .budget-page-head,
  .budget-head-actions,
  .proposal-inline-footer {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .actions,
  .search {
    width: 100%;
  }

  .actions .button,
  .actions button,
  .search input,
  .search button {
    width: 100%;
  }

  .grid-form,
  .report-editor-form,
  .budget-data-form,
  .estimate-fields,
  .compact-form,
  .cost-control-kpis,
  .project-entry-form,
  .line-main,
  .line-numbers,
  .item-composer,
  .room-composer,
  .proposal-form {
    grid-template-columns: 1fr;
  }

  .auth-brand,
  .auth-card {
    padding: 24px;
  }

  .auth-brand h1 {
    font-size: 28px;
  }

  .metrics strong {
    font-size: 22px;
  }

  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  th,
  td {
    white-space: nowrap;
  }

  .table-card {
    border: 0;
    overflow: visible;
    box-shadow: none;
  }

  .table-card thead {
    display: none;
  }

  .table-card,
  .table-card tbody,
  .table-card tr,
  .table-card td {
    display: block;
    width: 100%;
  }

  .table-card tr {
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: 0 8px 22px rgba(16,47,54,.05);
  }

  .table-card td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    align-items: flex-start;
  }

  .table-card td:last-child {
    border-bottom: 0;
  }

  .table-card td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .06em;
    flex: 0 0 40%;
    max-width: 40%;
  }

  .table-card td > * {
    text-align: right;
  }

  .critical-actions .button,
  .critical-actions button,
  .critical-actions a {
    width: 100%;
  }
}
.proposal-header {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  align-items: start;
  padding-bottom: 22px;
  border-bottom: 4px solid var(--brand);
}
.proposal-label {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.proposal-header h1 {
  font-size: 42px;
  margin-top: 4px;
  color: var(--brand);
}
.company-box {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: #f5f8f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: right;
}
.company-box span { color: #43525a; }
.proposal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 22px 0;
}
.proposal-grid > div,
.proposal-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.proposal-grid h2,
.proposal-section h2,
.proposal-bottom h2 {
  color: var(--brand);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.proposal-grid p,
.proposal-section p,
.proposal-bottom p { margin: 6px 0; }
.proposal-items th { background: var(--brand); color: #fff; }
.proposal-items td { vertical-align: top; }
.proposal-items tfoot td,
.proposal-items .grand-total-row td {
  border-top: 1px solid var(--line);
  background: #f5f8f7;
  font-weight: 800;
}
.proposal-items tfoot tr:first-child td {
  border-top: 2px solid var(--brand);
}
.proposal-items .grand-total-row td {
  background: var(--brand);
  color: #fff;
}
.contract-field {
  display: inline-block;
  min-width: 76px;
  color: #43525a;
  font-weight: 800;
}
.proposal-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  margin-top: 22px;
}
.proposal-total-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.proposal-total-box div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
}
.proposal-total-box div:last-child { border-bottom: 0; }
.proposal-total-box .grand-total {
  background: var(--brand);
  color: #fff;
  font-size: 18px;
}
.proposal-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 58px;
}
.contract-signature-date {
  margin: 44px 0 0;
  text-align: right;
  color: #303b40;
  font-weight: 700;
}
.contract-signature-block {
  break-inside: avoid;
  page-break-inside: avoid;
}
.proposal-signatures div {
  border-top: 1px solid #333;
  padding-top: 8px;
  text-align: center;
  color: #303b40;
  min-height: 54px;
  break-inside: avoid;
  page-break-inside: avoid;
}
.proposal-signatures .signature-name {
  display: block;
  color: #111;
  font-weight: 800;
  line-height: 1.35;
}
.proposal-signatures .signature-role {
  display: block;
  margin-top: 2px;
  color: #43525a;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.inspection-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  align-items: stretch;
}
.inspection-hero h2 { margin-top: 12px; }
.inspection-facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.inspection-facts div {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 118px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.inspection-facts span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.inspection-facts strong { font-size: 20px; }
.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.workflow-strip div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
}
.workflow-strip strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #edf2f1;
}
.workflow-strip .done {
  border-color: #b9ded4;
  background: var(--accent-soft);
  color: var(--accent);
}
.workflow-strip .done strong {
  background: var(--accent);
  color: #fff;
}
.inspection-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, .8fr);
  gap: 18px;
  align-items: start;
}
.room-composer {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.room-list {
  display: grid;
  gap: 12px;
}
.room-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.room-card > .room-summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
}
.room-card > .room-summary span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 900;
  grid-row: span 2;
}
.room-card p { margin: 0; color: #3d4b52; }
.empty-state.compact { min-height: 120px; margin-top: 14px; }
.room-photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.room-photo-strip figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.room-photo-strip img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
}
.room-photo-strip figcaption {
  padding: 6px;
  color: var(--muted);
  font-size: 12px;
}
.photo-edit-toggle {
  width: calc(100% - 12px);
  margin: 0 6px 6px;
}
.room-photo-upload {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 12px;
  background: #f6f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.room-photo-upload label:first-of-type,
.room-photo-upload .full {
  grid-column: 1 / -1;
}
.room-photo-upload button {
  justify-self: start;
}
.photo-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}
.photo-edit-form label,
.room-photo-upload label {
  min-width: 0;
}
.photo-edit-form .full,
.photo-edit-form .form-actions {
  grid-column: 1 / -1;
}
.photo-edit-form textarea {
  min-height: 120px;
}
.photo-delete-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.supplier-ledger-table {
  table-layout: fixed;
}
.supplier-ledger-table th:nth-child(1),
.supplier-ledger-table td:nth-child(1) {
  width: 110px;
}
.supplier-ledger-table th:nth-child(3),
.supplier-ledger-table td:nth-child(3) {
  width: 150px;
}
.supplier-ledger-table th:nth-child(4),
.supplier-ledger-table td:nth-child(4) {
  width: 150px;
}
.supplier-ledger-table td:nth-child(2) {
  min-width: 320px;
}
.supplier-ledger-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0;
  margin-bottom: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.supplier-ledger-summary div {
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  background: transparent;
}
.supplier-ledger-summary div:last-child {
  border-right: 0;
}
.supplier-ledger-summary span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.supplier-ledger-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
}
@media (max-width: 860px) {
  .supplier-ledger-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .supplier-ledger-summary div:nth-child(2n) {
    border-right: 0;
  }
  .supplier-ledger-summary div:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }
}
.print-target-output {
  display: none;
}
.inspection-guidance {
  align-self: start;
}
.evidence-checklist {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 16px 0;
}
.evidence-checklist div,
.hint-box {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: #f6f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.evidence-checklist strong {
  color: var(--brand);
  font-size: 24px;
}
.evidence-checklist span,
.hint-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.orphan-photos {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.orphan-photos h3 {
  margin-bottom: 4px;
}

.print-document {
  width: 210mm;
  max-width: calc(100vw - 24px);
  min-height: 297mm;
  margin: 18px auto 36px;
  padding: 18mm;
  background: #fff;
  color: #1b252b;
  box-shadow: var(--shadow);
}
.print-document table { margin: 18px 0; }

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }
  body.printing-target-only > :not(.print-target-output) {
    display: none !important;
  }
  body.printing-target-only .print-target-output {
    display: block !important;
    color: #17202a;
  }
  body.printing-target-only .print-target-output h1 {
    margin: 0 0 16px;
    font-size: 22px;
  }
  body.printing-target-only .print-target-output .print-filter-note {
    margin: -8px 0 12px;
    color: #55616a;
    font-size: 11px;
    font-weight: 700;
  }
  body.printing-target-only .print-target-output .table-responsive {
    overflow: visible;
  }
  body.printing-target-only .print-target-output .supplier-ledger-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    margin-bottom: 12px;
    border-top: 1px solid #d9e4e1;
    border-bottom: 1px solid #d9e4e1;
  }
  body.printing-target-only .print-target-output .supplier-ledger-summary div {
    padding: 6px 7px;
    border-right: 1px solid #d9e4e1;
    background: transparent !important;
  }
  body.printing-target-only .print-target-output .supplier-ledger-summary div:last-child {
    border-right: 0;
  }
  body.printing-target-only .print-target-output .supplier-ledger-summary span {
    display: block;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
  }
  body.printing-target-only .print-target-output .supplier-ledger-summary strong {
    display: block;
    margin-top: 3px;
    font-size: 11px;
  }
  body.printing-target-only .print-target-output table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 11px;
  }
  body.printing-target-only .print-target-output th,
  body.printing-target-only .print-target-output td {
    padding: 7px;
    border: 1px solid #d9e4e1;
    vertical-align: top;
  }
  body.printing-target-only .print-target-output th {
    background: #f4f8f7 !important;
    text-transform: uppercase;
  }
  body.printing-target-only .print-target-output .badge {
    border: 1px solid #d9e4e1;
    background: #fff !important;
    color: #17202a !important;
  }
  html,
  body {
    width: auto;
    min-height: auto;
    background: #fff !important;
    color: #111 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .no-print, .sidebar, .topbar { display: none !important; }
  .shell { display: block; }
  .content,
  .workspace {
    display: block;
    width: auto;
    max-width: none;
    padding: 0;
    background: #fff;
  }
  .print-document {
    width: auto;
    max-width: none;
    min-height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .panel { border: 0; }
  .page-head { display: none; }
  .mobile-tabbar { display: none !important; }
}

/* UI/UX refinement: clearer hierarchy, calmer surfaces and stronger mobile flow. */
@media screen {
  :root {
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --focus-ring: 0 0 0 3px rgba(28, 128, 116, .18);
  }

  :where(a, button, input, select, textarea):focus-visible {
    outline: 0;
    box-shadow: var(--focus-ring);
  }

  .content > .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(14px);
  }

  .topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border-radius: 14px;
  }

  .topbar-avatar {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, #173f46, #277c78);
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 900;
    letter-spacing: .03em;
  }

  .topbar-user-copy {
    display: grid;
    min-width: 0;
    gap: 1px;
  }

  .topbar-user-copy strong,
  .topbar-user-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-user-copy span {
    display: block;
  }

  .tenant-pill {
    max-width: min(38vw, 340px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar nav a {
    transition: background-color .16s ease, color .16s ease, transform .16s ease;
  }

  .sidebar nav a:not(.active):hover {
    transform: translateX(2px);
  }

  .workspace {
    max-width: 1560px;
  }

  .workspace .page-head {
    margin-bottom: 22px;
  }

  .workspace .page-head h1,
  .workspace .dashboard-hero h1 {
    letter-spacing: -.035em;
  }

  .workspace .page-head .muted,
  .workspace .dashboard-hero .muted {
    max-width: 660px;
    line-height: 1.6;
  }

  .workspace .search {
    margin-bottom: 18px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.72);
  }

  .workspace .search .form-control {
    min-height: 44px;
    border-color: #dbe4e0;
    border-radius: 11px;
  }

  .workspace .search .btn {
    min-height: 44px;
    border-radius: 11px;
  }

  .dashboard-hero {
    align-items: end;
    padding-top: 10px;
  }

  .dashboard-hero .eyebrow {
    color: var(--accent, #2f7668);
    font-weight: 850;
  }

  .dashboard-actions .btn {
    min-height: 42px;
    border-radius: 11px;
  }

  .dashboard-kpi-card,
  .dashboard-card {
    border-radius: var(--radius-md);
    box-shadow: 0 10px 26px rgba(22, 29, 33, .045);
  }

  .dashboard-kpi-card {
    transition: transform .18s ease, box-shadow .18s ease;
  }

  .dashboard-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(22, 29, 33, .08);
  }

  .table-responsive {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .table-responsive > .table {
    margin-bottom: 0;
  }

  .table thead th {
    color: var(--muted);
    background: #f8faf9;
    border-bottom-color: var(--line);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .table tbody tr {
    transition: background-color .14s ease;
  }

  .table tbody tr:hover {
    --bs-table-hover-bg: #f7fbf9;
  }

  .table td,
  .table th {
    padding: .9rem .95rem;
    vertical-align: middle;
  }

  .table .actions {
    white-space: nowrap;
  }

  .table .actions .btn + .btn {
    margin-left: 5px;
  }

  .empty-state {
    border-radius: var(--radius-lg);
    border-style: dashed;
    background: linear-gradient(180deg, #fff, #fbfdfc);
  }

  .mobile-tabbar a {
    min-height: 58px;
    gap: 3px;
    font-size: .72rem;
    font-weight: 800;
  }
}

@media screen and (max-width: 760px) {
  .content > .topbar {
    min-height: 64px;
    padding-inline: 14px;
  }

  .topbar-user {
    padding: 6px 9px;
  }

  .topbar-user-copy span {
    display: none;
  }

  .tenant-pill {
    display: none;
  }

  .workspace {
    padding: 18px 14px 88px;
  }

  .workspace .page-head {
    margin-bottom: 16px;
  }

  .workspace .search {
    padding: 10px;
  }

  .workspace .table-responsive {
    border: 0;
    background: transparent;
  }

  .workspace .mobile-stack-table tr {
    border-radius: var(--radius-md);
    box-shadow: 0 6px 18px rgba(22, 29, 33, .045);
  }

  .workspace .mobile-stack-table td {
    min-height: 48px;
  }

  .workspace .mobile-stack-table td[data-label="Ações"] {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: left !important;
  }

  .workspace .mobile-stack-table td[data-label="Ações"]::before {
    margin-bottom: 1px;
  }

  .workspace .mobile-stack-table .actions .btn {
    width: 100%;
  }

  .workspace .mobile-stack-table .actions .btn + .btn {
    margin-left: 0;
  }
}

@media (max-width: 980px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .shell { display: block; min-height: 100vh; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(86vw, 340px);
    height: 100dvh;
    transform: translateX(-104%);
    transition: transform .2s ease;
    box-shadow: 24px 0 48px rgba(0,0,0,.24);
  }
  .nav-toggle:checked + .shell .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(9, 20, 24, .48);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .nav-toggle:checked + .shell .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
  }
  .mobile-menu-button {
    display: inline-flex;
    min-height: 44px;
    padding: 9px 12px;
    background: #fff;
    color: var(--brand);
    border-color: var(--line);
    border: 1px solid var(--line);
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
  }
  .topbar {
    position: sticky;
    top: 0;
    min-height: 58px;
    padding: 8px 12px;
    background: rgba(244,246,245,.96);
  }
  .topbar > div:first-of-type {
    min-width: 0;
  }
  .topbar strong,
  .topbar span {
    max-width: 46vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tenant-pill { display: none; }
  .workspace { padding: 14px 12px 22px; }
  .columns, .grid-form, .report-editor-form, .billing-notice, .project-kpis, .project-hero, .project-cashflow, .project-sections, .project-entry-form, .budget-data-form, .budget-builder, .budget-page-head, .budget-studio, .estimate-editor, .estimate-header, .estimate-fields, .estimate-item-entry, .estimate-items-head, .estimate-item-row, .room-photo-upload, .photo-edit-form, .proposal-card, .field-grid.two, .proposal-inline-footer, .line-main, .line-numbers, .line-item-card, .proposal-header, .proposal-grid, .proposal-bottom, .proposal-signatures, .inspection-hero, .inspection-workspace, .workflow-strip { grid-template-columns: 1fr; }
  .supplier-quote-card-head,
  .supplier-quote-facts {
    grid-template-columns: 1fr;
  }
  .supplier-quote-card-head {
    display: grid;
  }
  .supplier-quote-card-head > strong {
    white-space: normal;
  }
  .budget-summary { position: static; }
  .estimate-summary { position: static; order: -1; }
  .estimate-status-box { justify-items: start; }
  .estimate-savebar button { width: 100%; }
  .estimate-items-head { display: none; }
  .estimate-items {
    border: 0;
    overflow: visible;
  }
  .estimate-item-row {
    min-width: 0;
    gap: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
  .estimate-item-row form,
  .estimate-item-row button { width: 100%; }
  .proposal-sidebar { position: static; order: -1; }
  .budget-head-actions { grid-auto-flow: row; width: 100%; }
  .budget-head-actions .button,
  .budget-head-actions form,
  .budget-head-actions button { width: 100%; }
  .proposal-card { padding: 14px; }
  .proposal-card-number { width: 32px; height: 32px; }
  .line-item-title { display: grid; }
  .line-item-card form,
  .line-item-card button { width: 100%; }
  .item-composer, .room-composer { grid-template-columns: 1fr; }
  .item-composer .span-2 { grid-column: auto; }
  .item-composer button { width: 100%; }
  .page-head {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-head .actions,
  .page-head .actions .button,
  .page-head .actions form,
  .page-head .actions button {
    width: 100%;
  }
  h1 { font-size: 25px; }
  h2 { font-size: 18px; }
  .panel,
  .print-document {
    padding: 14px;
    margin-bottom: 14px;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .metrics div {
    min-height: 96px;
    padding: 14px;
  }
  .metrics strong { font-size: 22px; }
  input,
  select,
  textarea,
  button,
  .button {
    min-height: 48px;
    font-size: 16px;
  }
  .inline-form,
  .search,
  .actions {
    align-items: stretch;
  }
  .inline-form > *,
  .search > * {
    flex: 1 1 100%;
  }
  .grid-form,
  .clean-form {
    gap: 12px;
    padding: 14px;
  }
  .form-actions {
    justify-content: stretch;
  }
  .form-actions button,
  .form-actions .button {
    width: 100%;
  }
  .billing-notice > div:last-child {
    min-width: 0;
    text-align: left;
  }
  .billing-notice .button {
    width: 100%;
  }
  .clean-form { padding: 0; }
  table {
    display: block;
    border: 0;
    background: transparent;
    overflow: visible;
  }
  table tbody,
  table tr,
  table td {
    display: block;
    width: 100%;
  }
  table tr:first-child {
    display: none;
  }
  table tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }
  table td {
    min-height: 42px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
  }
  table td:last-child {
    border-bottom: 0;
  }
  table td .actions,
  table td form,
  table td button,
  table td .button {
    width: 100%;
  }
  .budget-summary {
    order: -1;
  }
  .summary-line,
  .summary-total {
    padding: 10px 0;
  }
  .item-composer,
  .room-composer {
    padding: 12px;
  }
  .budget-items-table td:nth-child(2) {
    min-width: 0;
  }
  .inspection-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .inspection-facts div {
    min-height: 86px;
    padding: 8px;
  }
  .inspection-facts strong {
    font-size: 16px;
    overflow-wrap: anywhere;
  }
  .workflow-strip {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
  }
  .workflow-strip div {
    min-width: 160px;
    scroll-snap-align: start;
  }
  .room-card {
    padding: 12px;
  }
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .gallery img {
    height: 122px;
  }
  .proposal-document {
    margin: 0;
    padding: 16px;
    border: 0;
    box-shadow: none;
  }
  .proposal-header h1 {
    font-size: 30px;
  }
  .company-box {
    text-align: left;
  }
  .print-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0;
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }
  .print-toolbar .button,
  .print-toolbar button {
    flex: 1 1 0;
  }
  .proposal-document table,
  .proposal-document tbody,
  .proposal-document tr,
  .proposal-document td {
    display: revert;
    width: auto;
  }
  .proposal-document table {
    display: table;
    overflow-x: auto;
  }
  .proposal-document tr:first-child {
    display: table-row;
  }
  .proposal-document tr {
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
  }
  .proposal-document td {
    white-space: normal;
  }
  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
    gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 28px rgba(23,33,39,.10);
    backdrop-filter: blur(10px);
  }
  .mobile-tabbar a {
    display: grid;
    place-items: center;
    min-height: 48px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
  .mobile-tabbar a.active {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
  }
}

@media (max-width: 1360px) {
  .estimate-editor {
    grid-template-columns: 1fr;
  }
  .estimate-summary {
    position: static;
    order: -1;
  }
  .estimate-summary-card {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0 14px;
    align-items: end;
  }
  .estimate-summary-card .eyebrow,
  .estimate-summary-card .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .estimate-summary-card {
    grid-template-columns: 1fr;
  }
  .estimate-items {
    border: 0;
    overflow: visible;
  }
  .estimate-items-head {
    display: none;
  }
  .estimate-item-row {
    grid-template-columns: 1fr 1fr;
    min-width: 0;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 0 rgba(23,33,39,.03);
  }
  .estimate-item-row > div:first-child,
  .estimate-item-row > div:last-child {
    grid-column: 1 / -1;
  }
  .estimate-item-row form,
  .estimate-item-row button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 22px;
  }
  .topbar strong,
  .topbar span {
    max-width: 38vw;
  }
  .metrics {
    grid-template-columns: 1fr 1fr;
  }
  .metrics span {
    font-size: 10px;
  }
  .gallery {
    grid-template-columns: 1fr;
  }
  .inspection-facts {
    grid-template-columns: 1fr;
  }
  .proposal-grid > div,
  .proposal-section {
    padding: 12px;
  }
}

/* Final budget print override to neutralize older print rules */
.budget-print-page .proposal-document {
  width: 210mm;
  max-width: calc(100vw - 24px);
  margin: 18px auto 36px;
  padding: 18mm;
  background: #fff;
  color: #1b252b;
  border: 1px solid #d7d7d7;
  border-radius: 0;
  box-shadow: var(--shadow);
}

.budget-print-page .proposal-header {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  align-items: start;
  padding-bottom: 22px;
  border-bottom: 4px solid var(--brand);
}

.budget-print-page .proposal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 22px 0;
}

.budget-print-page .proposal-grid > div,
.budget-print-page .proposal-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.budget-print-page .proposal-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  margin-top: 22px;
}

.budget-print-page .proposal-total-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.budget-print-page .proposal-total-box .grand-total {
  background: var(--brand);
  color: #fff;
}

.budget-print-page .proposal-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-top: 58px;
}

.budget-print-page .proposal-items {
  width: 100%;
  border-collapse: collapse;
}

.budget-print-page .proposal-items th {
  background: var(--brand);
  color: #fff;
}

.budget-print-page .proposal-items td {
  vertical-align: top;
}

@media (min-width: 981px) {
  .mobile-tabbar { display: none !important; }
}

@media print {
  .proposal-document {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    min-height: auto;
    border: 0;
    box-shadow: none;
  }
  .proposal-header {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .proposal-section,
  .proposal-grid > div,
  .proposal-total-box,
  .contract-signature-block,
  .contract-signature-date,
  .proposal-signatures {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .contract-signature-block {
    display: block !important;
    margin-top: 12mm;
    page-break-inside: avoid;
  }
  .contract-signature-date {
    display: block !important;
    margin: 0 0 18mm;
    text-align: right;
  }
  .proposal-signatures {
    display: table !important;
    width: 100%;
    table-layout: fixed;
    margin-top: 0;
    page-break-inside: avoid;
  }
  .proposal-signatures div {
    display: table-cell !important;
    width: 50%;
    min-height: 0;
    padding-top: 8px;
    vertical-align: top;
    border-top: 1px solid #111 !important;
  }
  .proposal-signatures div:first-child {
    padding-right: 9mm;
  }
  .proposal-signatures div + div {
    padding-left: 9mm;
  }
  .proposal-signatures div,
  .proposal-signatures .signature-name,
  .proposal-signatures .signature-role {
    color: #111 !important;
  }
  .proposal-items {
    font-size: 11px;
  }
  .proposal-items th,
  .proposal-items td {
    padding: 7px;
  }
}

/* Bootstrap 5 integration and responsive hardening */
:root {
  --radius-md: .5rem;
  --radius-lg: .75rem;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-primary: var(--brand);
  --bs-primary-rgb: 23, 63, 70;
  --bs-link-color: var(--brand);
  --bs-link-hover-color: var(--brand-strong);
  --bs-border-color: var(--line);
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.workspace {
  max-width: 1440px;
  margin-inline: 0;
}

.button,
button:not(.sidebar-backdrop) {
  --bs-btn-padding-x: .875rem;
  --bs-btn-padding-y: .5rem;
  --bs-btn-border-radius: .75rem;
}

.button {
  min-width: max-content;
}

.button.secondary,
button.secondary,
table button {
  color: var(--brand);
}

.actions {
  min-width: 0;
}

.actions .button,
.actions button {
  white-space: nowrap;
}

.metrics.row {
  display: flex;
  margin-bottom: 20px;
}

.metrics.row > [class*="col"] {
  display: block;
  position: relative;
  min-height: 104px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}

.metrics.row > [class*="col"]::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  opacity: .75;
}

.form-control,
.form-select,
input,
select,
textarea {
  border-radius: var(--radius-md);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(47,118,104,.18);
}

.was-validated input:invalid,
.was-validated select:invalid,
.was-validated textarea:invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 .2rem rgba(180,35,24,.12);
}

.was-validated input:valid,
.was-validated select:valid,
.was-validated textarea:valid {
  border-color: #86c8a8;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 10px 22px rgba(16, 47, 54, .04);
  -webkit-overflow-scrolling: touch;
}

.table-responsive > table {
  min-width: 760px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.table-responsive .table {
  --bs-table-bg: var(--surface);
  --bs-table-hover-bg: #fbfdfc;
  --bs-table-border-color: var(--line);
}

.table-responsive th {
  white-space: nowrap;
}

.table-responsive td {
  overflow-wrap: anywhere;
}

.table-responsive .actions {
  justify-content: flex-end;
}

.alert {
  border-width: 1px;
}

.alert-success {
  background: #e7f5ee;
  border-color: #bfe2d0;
  color: #12633f;
}

.alert-danger {
  background: #fdecea;
  border-color: #efc2bd;
  color: #9c1f16;
}

.badge {
  line-height: 1.2;
}

.empty-state .button {
  margin-top: 6px;
}

@media (max-width: 980px) {
  .table-responsive {
    border-radius: var(--radius-lg);
    overflow-x: auto;
  }

  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive th,
  .table-responsive td {
    display: revert;
    width: auto;
  }

  .table-responsive table {
    display: table;
    min-width: 720px;
    border: 0;
    background: var(--surface);
  }

  .table-responsive tr:first-child {
    display: table-row;
  }

  .table-responsive tr {
    margin-bottom: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  .table-responsive td,
  .table-responsive th {
    display: table-cell;
    white-space: nowrap;
  }

  .table-responsive td .actions,
  .table-responsive td form,
  .table-responsive td button,
  .table-responsive td .button {
    width: auto;
  }

  .table-responsive .actions {
    flex-wrap: nowrap;
  }
}

@media (max-width: 576px) {
  .workspace {
    padding-left: 12px;
    padding-right: 12px;
  }

  .page-head .button,
  .page-head button,
  .actions .button,
  .actions button {
    width: 100%;
    min-width: 0;
  }

  .metrics.row > [class*="col"] {
    min-height: 92px;
    padding: 14px;
  }

.table-responsive > table {
    min-width: 680px;
  }
}

/* Budget editor polish */
.estimate-editor {
  gap: 24px;
}

.estimate-sheet {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.estimate-sheet .form-page {
  gap: 0;
}

.estimate-sheet .form-section {
  margin: 0;
  padding: 24px 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.estimate-sheet .form-section:last-child {
  border-bottom: 0;
}

.estimate-sheet .section-head {
  margin-bottom: 18px;
}

.estimate-sheet .section-head h2 {
  margin-bottom: 6px;
}

.estimate-sheet .section-head p {
  max-width: 72ch;
  margin: 0;
}

.estimate-header {
  grid-template-columns: minmax(0, 1fr) minmax(220px, auto);
  gap: 24px;
  padding: 26px 28px;
  background: #f7faf9;
}

.estimate-header label {
  max-width: 760px;
}

.estimate-status-box {
  align-self: center;
  padding: 14px 0 0 24px;
  border-left: 1px solid var(--line);
}

.estimate-status-box .badge {
  margin-bottom: 8px;
}

.estimate-fields,
.estimate-textareas,
.estimate-item-entry {
  gap: 18px;
}

.estimate-sheet label {
  gap: 8px;
  min-width: 0;
}

.estimate-sheet input,
.estimate-sheet select,
.estimate-sheet textarea {
  min-height: 48px;
  padding: 11px 13px;
  line-height: 1.35;
}

.estimate-sheet textarea {
  min-height: 128px;
}

.estimate-savebar {
  padding: 18px 28px;
  background: #f7faf9;
  border-bottom: 1px solid var(--line);
}

.estimate-sheet > .form-section {
  padding: 24px 28px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.estimate-item-entry {
  padding: 18px;
  margin-bottom: 18px;
  border-radius: var(--radius-lg);
}

.estimate-items {
  border-radius: var(--radius-lg);
}

.estimate-items-head,
.estimate-item-row {
  padding: 14px 16px;
}

.estimate-item-row > * {
  min-width: 0;
}

.estimate-item-row small {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.estimate-summary-card {
  border-radius: var(--radius-lg);
}

@media (max-width: 1360px) {
  .estimate-summary-card {
    align-items: stretch;
  }
}

@media (max-width: 980px) {
  .estimate-sheet .form-section,
  .estimate-sheet > .form-section,
  .estimate-header,
  .estimate-savebar {
    padding: 18px;
  }

  .estimate-header {
    gap: 18px;
  }

  .estimate-status-box {
    padding: 16px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 576px) {
  .estimate-sheet .form-section,
  .estimate-sheet > .form-section,
  .estimate-header,
  .estimate-savebar {
    padding: 16px 14px;
  }

  .estimate-sheet h2 {
    font-size: 1.1rem;
    line-height: 1.25;
  }

  .estimate-fields,
  .estimate-textareas,
  .estimate-item-entry {
    gap: 14px;
  }
}

/* Budget editor hard override: keep content away from card borders */
.estimate-sheet > form.form-page > section.form-section,
.estimate-sheet > section.form-section {
  padding: 28px 32px;
}

.estimate-sheet > form.form-page > section.form-section.estimate-header {
  padding: 28px 32px;
}

.estimate-sheet > form.form-page > section.form-section > .section-head,
.estimate-sheet > section.form-section > .section-head {
  padding: 0;
  margin: 0 0 20px;
}

.estimate-sheet > form.form-page > section.form-section > .estimate-fields,
.estimate-sheet > form.form-page > section.form-section > .estimate-textareas,
.estimate-sheet > section.form-section > .estimate-item-entry,
.estimate-sheet > section.form-section > .empty-state,
.estimate-sheet > section.form-section > .estimate-items,
.estimate-sheet > section.form-section > .simple-list {
  margin-inline: 0;
}

.estimate-sheet > form.form-page > .estimate-savebar {
  padding: 20px 32px;
}

@media (max-width: 980px) {
  .estimate-sheet > form.form-page > section.form-section,
  .estimate-sheet > section.form-section,
  .estimate-sheet > form.form-page > section.form-section.estimate-header {
    padding: 22px 20px;
  }

  .estimate-sheet > form.form-page > .estimate-savebar {
    padding: 18px 20px;
  }
}

@media (max-width: 576px) {
  .estimate-sheet > form.form-page > section.form-section,
  .estimate-sheet > section.form-section,
  .estimate-sheet > form.form-page > section.form-section.estimate-header {
    padding: 18px 14px;
  }

  .estimate-sheet > form.form-page > .estimate-savebar {
    padding: 16px 14px;
  }
}

/* Sidebar must behave like an app rail, not like a rounded card */
@media (min-width: 981px) {
  .shell {
    min-height: 100dvh;
    align-items: stretch;
    background: linear-gradient(90deg, #102f36 0 280px, transparent 280px);
  }

  .sidebar {
    min-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
  }
}

@media (max-width: 980px) {
  .shell {
    background: transparent;
  }

  .sidebar {
    border-radius: 0;
  }
}

/* Fixed and collapsible desktop sidebar */
:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 72px;
}

@media (min-width: 981px) {
  body {
    background: #f6f8f8;
  }

  .shell {
    display: block;
    min-height: 100dvh;
    background: transparent;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    padding: 24px 18px;
    background: #0f3036;
    box-shadow: none;
    overflow-x: hidden;
    overflow-y: auto;
    transition: width .18s ease, padding .18s ease;
  }

  .content {
    min-height: 100dvh;
    margin-left: var(--sidebar-width);
    transition: margin-left .18s ease;
  }

  .sidebar-collapse-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 22px;
    right: 14px;
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 999px;
    background: transparent;
    color: #cfe1e3;
    font-size: 0;
    font-weight: 900;
  }

  .sidebar-collapse-button:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
  }

  .sidebar-collapse-icon {
    position: relative;
    display: block;
    width: 9px;
    height: 9px;
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    transform: translateX(2px) rotate(135deg);
    transition: transform .18s ease;
  }

  .brand {
    min-height: 50px;
    padding: 0 44px 20px 0;
    border-bottom: 1px solid rgba(255,255,255,.10);
  }

  .brand strong {
    font-size: 22px;
    line-height: 1.1;
  }

  .brand small {
    margin-top: 4px;
    color: #9eb9bd;
  }

  .sidebar nav {
    gap: 3px;
    padding-top: 8px;
  }

  .nav-group {
    margin: 18px 10px 8px;
    color: #91aeb3;
    letter-spacing: .12em;
  }

  .sidebar a:not(.brand),
  .link-button {
    min-height: 42px;
    border-radius: 10px;
    color: #e8f1f2;
    font-weight: 750;
  }

  .sidebar a:hover,
  .link-button:hover {
    background: rgba(255,255,255,.08);
  }

  .sidebar a.active {
    background: rgba(255,255,255,.14);
    color: #fff;
  }

  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    padding-inline: 12px;
  }

  body.sidebar-collapsed .content {
    margin-left: var(--sidebar-collapsed-width);
  }

  body.sidebar-collapsed .brand {
    display: none;
  }

  body.sidebar-collapsed .nav-group,
  body.sidebar-collapsed .context-label,
  body.sidebar-collapsed .sidebar-footer,
  body.sidebar-collapsed .sidebar-search {
    display: none;
  }

  body.sidebar-collapsed .sidebar nav {
    gap: 8px;
  }

  body.sidebar-collapsed .sidebar a:not(.brand),
  body.sidebar-collapsed .link-button {
    justify-content: center;
    min-height: 44px;
    padding: 10px 8px;
    overflow: hidden;
    white-space: nowrap;
  }

  body.sidebar-collapsed .sidebar a:not(.brand) {
    font-size: 0;
  }

  body.sidebar-collapsed .sidebar a:not(.brand)::before {
    content: attr(data-initial);
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: transparent;
    color: #eef7f7;
    font-size: 14px;
    font-weight: 900;
  }

  body.sidebar-collapsed .sidebar a:not(.brand):focus-visible::before {
    background: #b5f2dc;
    color: #0f3036;
  }

  body.sidebar-collapsed .sidebar-collapse-button {
    top: 18px;
    right: 19px;
  }

  body.sidebar-collapsed .sidebar-collapse-icon {
    transform: translateX(-2px) rotate(-45deg);
  }
}

@media (max-width: 980px) {
  .sidebar-collapse-button {
    display: none;
  }

  .content {
    margin-left: 0;
  }
}

.legal-document {
  display: grid;
  gap: 18px;
  max-width: 860px;
}

.legal-document section {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.legal-document h1 {
  color: var(--brand);
}

.legal-document h2 {
  margin: 0;
}

.checkbox-field {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 10px;
  font-weight: 700;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.checkbox-field span {
  min-width: 0;
}

.project-detail .card {
  border-color: var(--line);
  border-radius: 8px;
}

.project-detail .nav-tabs {
  gap: 4px;
}

.project-detail .nav-tabs .nav-link {
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.project-detail .nav-tabs .nav-link.active {
  color: var(--brand);
}

.project-detail .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-height: 38px;
}

.project-detail .btn-sm {
  min-height: 31px;
}

.project-detail .form-label {
  font-weight: 800;
  color: var(--ink);
}

.project-detail .table th {
  white-space: nowrap;
}

.project-detail .list-group-item {
  background: transparent;
}

.project-detail .table-tools,
.project-list .table-tools {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-bottom: .75rem;
}

.project-detail .table-tools .form-control,
.project-list .table-tools .form-control {
  max-width: 360px;
}

.project-detail .table-pagination,
.project-list .table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-top: .75rem;
}

.project-detail .table-pagination-summary,
.project-list .table-pagination-summary {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 700;
}

.project-list .project-summary-card {
  border-color: var(--line);
  border-radius: 8px;
}

.project-list .project-summary-card .card-body {
  display: grid;
  gap: .35rem;
}

.project-list .project-summary-card span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 850;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.project-list .project-summary-card strong {
  color: var(--ink);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.15;
}

.project-list .project-summary-card small {
  color: var(--muted);
  font-weight: 650;
}

.project-list .project-list-panel {
  border-color: var(--line);
  border-radius: 8px;
}

.project-list .project-index-table {
  table-layout: fixed;
  min-width: 920px;
}

.project-list .project-index-table th,
.project-list .project-index-table td {
  vertical-align: middle;
}

.project-list .project-index-table th:first-child,
.project-list .project-index-table td:first-child {
  width: 30%;
}

.project-list .project-index-table th:nth-child(2),
.project-list .project-index-table td:nth-child(2) {
  width: 120px;
}

.project-list .project-index-table th:nth-child(3),
.project-list .project-index-table td:nth-child(3),
.project-list .project-index-table th:nth-child(4),
.project-list .project-index-table td:nth-child(4),
.project-list .project-index-table th:nth-child(5),
.project-list .project-index-table td:nth-child(5),
.project-list .project-index-table th:nth-child(6),
.project-list .project-index-table td:nth-child(6) {
  width: 140px;
}

.project-list .project-index-table th:nth-child(7),
.project-list .project-index-table td:nth-child(7) {
  width: 110px;
}

.project-list .project-address {
  max-width: 360px;
}

.project-list .project-margin-bar {
  width: 96px;
  height: .45rem;
}

.project-detail .project-cost-table th,
.project-detail .project-cost-table td {
  vertical-align: middle;
}

.project-detail .project-cost-table {
  table-layout: fixed;
  min-width: 760px;
}

.project-detail .project-cost-table td:first-child {
  width: auto;
}

.project-detail .project-cost-table th:nth-child(2),
.project-detail .project-cost-table td:nth-child(2) {
  width: 110px;
}

.project-detail .project-cost-table th:nth-child(3),
.project-detail .project-cost-table td:nth-child(3) {
  width: 150px;
}

.project-detail .project-cost-table th:nth-child(4),
.project-detail .project-cost-table td:nth-child(4) {
  width: 180px;
}

.project-detail .project-row-actions form {
  margin: 0;
}

.project-detail .project-row-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.project-detail .project-row-actions .btn {
  min-width: 74px;
  white-space: nowrap;
}

.project-detail .technical-table {
  margin-bottom: .5rem;
}

.project-detail .table-responsive-fit {
  overflow-x: visible;
}

.project-detail .table-responsive-fit > table {
  min-width: 0;
}

.project-detail .table-responsive-fit > .project-cost-table {
  min-width: 760px;
}

.project-detail .table-responsive-fit th,
.project-detail .table-responsive-fit td {
  white-space: normal;
}

.workspace .page-head {
  align-items: flex-start;
}

.workspace .page-head .actions,
.workspace .page-head > div:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
}

.workspace .button,
.workspace button:not(.btn-close):not(.nav-link):not(.sidebar-collapse):not(.mobile-menu-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-height: 38px;
}

.workspace .table-responsive {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.workspace .ux-table {
  margin-bottom: 0;
}

.workspace .ux-table th {
  white-space: nowrap;
}

.workspace .table-tools {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-bottom: .75rem;
}

.workspace .table-tools .form-control {
  max-width: 360px;
}

.workspace .table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-top: .75rem;
}

.workspace .table-pagination-summary {
  color: var(--muted);
  font-size: .875rem;
  font-weight: 700;
}

.workspace .panel,
.workspace .grid-form,
.workspace .form-page,
.workspace .empty-state {
  border-radius: 8px;
}

.workspace .panel {
  border-color: var(--line);
  box-shadow: 0 1px 0 rgba(23,33,39,.03);
}

.workspace .form-page {
  display: grid;
  gap: 1rem;
}

.workspace .grid-form,
.workspace .compact-grid {
  gap: 1rem;
}

.workspace label {
  color: var(--ink);
  font-weight: 750;
}

.workspace label input,
.workspace label select,
.workspace label textarea,
.workspace .grid-form input,
.workspace .grid-form select,
.workspace .grid-form textarea,
.workspace .form-page input,
.workspace .form-page select,
.workspace .form-page textarea,
.workspace .panel input,
.workspace .panel select,
.workspace .panel textarea {
  width: 100%;
  margin-top: .35rem;
}

.workspace .actions {
  gap: .5rem;
}

.workspace td.actions {
  align-items: center;
  justify-content: flex-end;
}

.workspace td.actions form {
  margin: 0;
}

.project-detail .modal {
  overscroll-behavior: contain;
}

.project-detail .modal.show,
.project-detail .modal[style*="display: block"] {
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.project-detail .project-modal-dialog {
  max-width: min(900px, calc(100vw - 1.5rem));
  margin: .75rem auto;
  min-height: 0;
}

.project-detail .project-modal-dialog .modal-content {
  max-height: none !important;
  overflow: visible;
}

.project-detail .project-modal-dialog .modal-body {
  max-height: none !important;
  overflow: visible !important;
}

@media (max-width: 720px) {
  .project-detail .project-modal-dialog {
    margin: .5rem;
    max-width: calc(100vw - 1rem);
  }

  .project-detail .modal-header,
  .project-detail .modal-footer {
    padding: .875rem 1rem;
  }

  .project-detail .modal-body {
    padding: 1rem;
  }

  .project-list .card-body,
  .project-detail .card-body {
    padding: 1rem;
  }

  .workspace {
    padding: 18px 14px 86px;
  }

  .workspace .page-head {
    flex-direction: column;
    gap: .875rem;
  }

  .workspace .page-head .actions,
  .workspace .page-head > div:last-child {
    display: grid;
    width: 100%;
  }

  .workspace .page-head .button,
  .workspace .page-head .btn,
  .workspace .page-head form,
  .workspace .page-head button {
    width: 100%;
  }

  .workspace .table-tools,
  .workspace .table-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace .table-tools .form-control {
    max-width: none;
  }

  .workspace .table-responsive {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  .workspace .mobile-stack-table {
    display: block;
    min-width: 0 !important;
    border: 0;
  }

  .workspace .mobile-stack-table thead {
    display: none;
  }

  .workspace .mobile-stack-table tbody,
  .workspace .mobile-stack-table tr,
  .workspace .mobile-stack-table td {
    display: block;
    width: 100%;
  }

  .workspace .mobile-stack-table tr {
    margin-bottom: .875rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(23,33,39,.03);
  }

  .workspace .mobile-stack-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem .875rem;
    border-bottom: 1px solid var(--line);
    text-align: right !important;
    white-space: normal;
  }

  .workspace .mobile-stack-table td:last-child {
    border-bottom: 0;
  }

  .workspace .mobile-stack-table td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .04em;
    text-align: left;
    text-transform: uppercase;
  }

  .workspace .mobile-stack-table td:first-child {
    display: block;
    text-align: left !important;
    background: #f8faf9;
  }

  .workspace .mobile-stack-table td:first-child::before {
    display: block;
    margin-bottom: .25rem;
  }

  .project-detail .btn,
  .project-detail .card-header .btn,
  .project-detail .card-header .btn + .btn {
    width: 100%;
  }

  .project-detail .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
  }

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

  .project-detail .table-responsive-fit {
    overflow-x: visible;
  }

  .project-detail .table-responsive-fit > table {
    min-width: 0;
  }

  .project-detail .table-tools,
  .project-list .table-tools,
  .project-detail .table-pagination,
  .project-list .table-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .project-detail .table-tools .form-control,
  .project-list .table-tools .form-control {
    max-width: none;
  }

  .project-list .table-responsive,
  .project-detail .table-responsive {
    overflow-x: visible;
  }

  .project-list .mobile-stack-table,
  .project-detail .mobile-stack-table,
  .project-detail .table-responsive-fit > .project-cost-table {
    display: block;
    min-width: 0;
    border: 0;
  }

  .project-list .mobile-stack-table thead,
  .project-detail .mobile-stack-table thead {
    display: none;
  }

  .project-list .mobile-stack-table tbody,
  .project-list .mobile-stack-table tr,
  .project-list .mobile-stack-table td,
  .project-detail .mobile-stack-table tbody,
  .project-detail .mobile-stack-table tr,
  .project-detail .mobile-stack-table td {
    display: block;
    width: 100%;
  }

  .project-list .mobile-stack-table tr,
  .project-detail .mobile-stack-table tr {
    margin-bottom: .875rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 0 rgba(23,33,39,.03);
  }

  .project-list .mobile-stack-table td,
  .project-detail .mobile-stack-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem .875rem;
    border-bottom: 1px solid var(--line);
    text-align: right !important;
    white-space: normal;
  }

  .project-list .mobile-stack-table td:last-child,
  .project-detail .mobile-stack-table td:last-child {
    border-bottom: 0;
  }

  .project-list .mobile-stack-table td::before,
  .project-detail .mobile-stack-table td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--muted);
    font-size: .72rem;
    font-weight: 850;
    letter-spacing: .04em;
    text-align: left;
    text-transform: uppercase;
  }

  .project-list .mobile-stack-table td > *,
  .project-detail .mobile-stack-table td > * {
    min-width: 0;
  }

  .project-list .mobile-stack-table td:first-child,
  .project-detail .mobile-stack-table td:first-child {
    display: block;
    text-align: left !important;
    background: #f8faf9;
  }

  .project-list .mobile-stack-table td:first-child::before,
  .project-detail .mobile-stack-table td:first-child::before {
    display: block;
    margin-bottom: .25rem;
  }

  .project-list .project-address {
    max-width: none;
  }

  .project-list .project-margin-bar {
    width: 112px;
  }

  .project-detail .project-row-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .project-detail .project-row-actions .btn,
  .project-detail .project-row-actions form {
    width: 100%;
  }
}

/* Clean navigation refresh - final cascade */
:root {
  --menu-bg: #f7f9f8;
  --menu-panel: #ffffff;
  --menu-line: #e5ebe8;
  --menu-ink: #222b30;
  --menu-muted: #7b888e;
  --menu-active: #173f46;
  --menu-active-soft: #e8f1f3;
  --menu-success: #3cc985;
}

body {
  background: #f4f6f6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255,255,255,.75), rgba(244,246,246,.92)),
    #f4f6f6;
}

.shell {
  background: transparent;
}

.sidebar {
  background: var(--menu-bg) !important;
  color: var(--menu-ink) !important;
  border-right: 1px solid var(--menu-line);
  box-shadow: 10px 0 28px rgba(22, 29, 33, .05) !important;
}

.brand {
  gap: 12px;
  min-height: 60px;
  color: var(--menu-ink) !important;
  border-bottom-color: var(--menu-line) !important;
}

.brand-mark {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 32% 33%, #fff 0 14%, transparent 15%),
    radial-gradient(circle at 68% 33%, #fff 0 14%, transparent 15%),
    linear-gradient(135deg, #1f5962, #173f46);
  color: transparent;
  box-shadow: 0 10px 20px rgba(109, 73, 189, .20);
}

.brand strong {
  color: var(--menu-ink);
  font-size: 18px !important;
  font-weight: 900;
}

.brand small {
  color: var(--menu-muted) !important;
  font-weight: 750;
}

.sidebar nav {
  gap: 2px;
}

.nav-group {
  margin: 18px 12px 8px !important;
  color: #9aa4a9 !important;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .06em !important;
}

.sidebar a:not(.brand),
.link-button {
  position: relative;
  min-height: 42px;
  border-radius: 12px !important;
  color: #3d484e !important;
  font-weight: 780 !important;
}

.sidebar a:not(.brand)::before,
.link-button::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 999px;
  background: #cad3d0;
}

.sidebar a:not(.brand):hover,
.link-button:hover {
  background: #eef2f0 !important;
  color: var(--menu-ink) !important;
}

.sidebar a.active {
  background: var(--menu-active-soft) !important;
  color: var(--menu-active) !important;
  box-shadow: inset 4px 0 0 var(--menu-active);
}

.sidebar a.active::before {
  background: var(--menu-active);
}

.context-label {
  color: var(--menu-ink) !important;
}

.sidebar-footer {
  border-top-color: var(--menu-line) !important;
}

.sidebar-collapse-button {
  border-color: var(--menu-line) !important;
  background: #fff !important;
  color: var(--menu-muted) !important;
  box-shadow: 0 4px 14px rgba(22, 29, 33, .08);
}

.sidebar-collapse-button:hover {
  background: #f0f4f2 !important;
  color: var(--menu-active) !important;
}

.topbar {
  min-height: 72px;
  background: rgba(255,255,255,.88) !important;
  border-bottom: 1px solid var(--menu-line);
  box-shadow: 0 4px 18px rgba(22, 29, 33, .04);
}

.topbar-user {
  padding: 8px 14px;
  border: 1px solid var(--menu-line);
  border-radius: 999px;
  background: #fff;
}

.topbar-user strong {
  color: var(--menu-ink);
  font-size: 14px;
}

.topbar-user span {
  color: var(--menu-muted);
  font-size: 12px;
}

.tenant-pill {
  border-color: #ccebdd;
  background: #eaf9f2;
  color: #21885c;
}

.mobile-menu-button,
.sidebar-close {
  border-radius: 999px !important;
  background: #fff !important;
  color: var(--menu-ink) !important;
  border-color: var(--menu-line) !important;
}

.mobile-tabbar {
  background: rgba(255,255,255,.94) !important;
  border-top-color: var(--menu-line) !important;
}

.mobile-tabbar a.active {
  background: var(--menu-active-soft) !important;
  color: var(--menu-active) !important;
}

body.sidebar-collapsed .sidebar a:not(.brand)::before,
body.sidebar-collapsed .link-button::before {
  display: none;
}

body.sidebar-collapsed .sidebar a:not(.brand)::after {
  content: attr(data-initial);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #fff;
  color: var(--menu-active);
  font-size: 14px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px var(--menu-line);
}

body.sidebar-collapsed .sidebar a.active::after {
  background: var(--menu-active);
  color: #fff;
  box-shadow: none;
}

@media (min-width: 981px) {
  :root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
  }

  .sidebar {
    padding: 22px 16px !important;
  }

  .content {
    background: transparent;
  }

  .workspace {
    padding-top: 32px;
  }
}

@media (max-width: 980px) {
  .sidebar {
    background: var(--menu-bg) !important;
    box-shadow: 20px 0 44px rgba(22, 29, 33, .16) !important;
  }

  .sidebar-close {
    margin-bottom: 12px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Management dashboard */
.dashboard-page {
  display: grid;
  gap: 22px;
}

.dashboard-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 2px;
}

.dashboard-hero h1 {
  margin: 4px 0 8px;
  color: #17242b;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: 0;
}

.dashboard-hero p {
  max-width: 760px;
  margin: 0;
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-kpi-card,
.dashboard-card {
  background: #fff;
  border: 1px solid #e5ebe8;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(22, 29, 33, .05);
}

.dashboard-kpi-card {
  position: relative;
  min-height: 136px;
  padding: 20px;
  overflow: hidden;
}

.dashboard-kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #173f46;
}

.dashboard-kpi-card span,
.dashboard-kpi-card small {
  display: block;
  color: #738188;
  font-weight: 750;
}

.dashboard-kpi-card span {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dashboard-kpi-card strong {
  display: block;
  margin: 12px 0 8px;
  color: #17242b;
  font-size: 29px;
  line-height: 1.08;
}

.dashboard-kpi-card strong.is-good {
  color: #20845b;
}

.dashboard-kpi-card strong.is-danger {
  color: #b83b3b;
}

.dashboard-kpi-card small {
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 16px;
}

.dashboard-card {
  min-width: 0;
  padding: 22px;
}

.dashboard-card-wide {
  min-height: 320px;
}

.dashboard-bars {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.dashboard-bar-row {
  display: grid;
  gap: 8px;
}

.dashboard-bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #17242b;
}

.dashboard-bar-label strong {
  font-size: 15px;
}

.dashboard-bar-label span {
  color: #6f7c83;
  font-weight: 800;
}

.dashboard-bar-track {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f2;
}

.dashboard-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #173f46;
}

.dashboard-bar-fill.received {
  background: #31ba78;
}

.dashboard-bar-fill.costs {
  background: #f0b429;
}

.dashboard-bar-fill.receivable {
  background: #4f7f8f;
}

.dashboard-insights {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.dashboard-insight {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
  border: 1px solid #e5ebe8;
  border-left-width: 5px;
  border-radius: 8px;
  background: #f9fbfa;
}

.dashboard-insight strong {
  color: #17242b;
  font-size: 14px;
}

.dashboard-insight span {
  color: #5f6d74;
  font-size: 13px;
  line-height: 1.45;
}

.dashboard-insight.good {
  border-left-color: #31ba78;
}

.dashboard-insight.info {
  border-left-color: #4f7f8f;
}

.dashboard-insight.warning {
  border-left-color: #f0b429;
}

.dashboard-insight.danger {
  border-left-color: #d95050;
}

.activity-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  min-height: 230px;
  margin-top: 22px;
  padding: 14px 4px 0;
  border-bottom: 1px solid #e5ebe8;
}

.activity-month {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 10px;
  min-width: 0;
  text-align: center;
}

.activity-month strong {
  color: #718087;
  font-size: 12px;
}

.activity-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 6px;
  min-height: 178px;
}

.activity-bar {
  display: block;
  width: 18px;
  border-radius: 999px 999px 0 0;
  background: #173f46;
}

.activity-bar.reports {
  background: #31ba78;
}

.activity-bar.budgets {
  background: #f0b429;
}

.dashboard-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  color: #5f6d74;
  font-size: 13px;
  font-weight: 800;
}

.dashboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dashboard-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #173f46;
}

.dashboard-legend i.reports {
  background: #31ba78;
}

.dashboard-legend i.budgets {
  background: #f0b429;
}

.pipeline-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.pipeline-list h3 {
  margin: 12px 0 2px;
  color: #17242b;
  font-size: 15px;
}

.pipeline-row,
.pipeline-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf1f2;
}

.pipeline-row span,
.pipeline-group > span {
  color: #5f6d74;
  font-weight: 780;
}

.pipeline-row strong,
.pipeline-group > strong {
  color: #173f46;
  font-size: 18px;
}

.pipeline-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.pipeline-tags em {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf3f4;
  color: #173f46;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.risk-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.risk-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid #e5ebe8;
  border-radius: 8px;
  background: #fbfcfc;
}

.risk-item span,
.risk-item small {
  display: block;
  color: #748188;
  font-size: 12px;
  font-weight: 750;
}

.risk-item strong {
  display: block;
  margin: 4px 0;
  color: #17242b;
  line-height: 1.25;
}

.risk-meter {
  display: grid;
  gap: 6px;
  text-align: right;
}

.risk-meter strong {
  margin: 0;
  color: #173f46;
}

.risk-meter span {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f2;
}

.risk-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #f0b429;
}

@media (max-width: 1180px) {
  .dashboard-kpi-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard-hero {
    display: grid;
  }

  .dashboard-actions {
    justify-content: stretch;
  }

  .dashboard-actions .btn {
    flex: 1 1 100%;
  }

  .dashboard-kpi-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-card {
    padding: 18px;
  }

  .activity-chart {
    gap: 8px;
    overflow-x: auto;
  }

  .activity-month {
    min-width: 72px;
  }

  .activity-bar {
    width: 14px;
  }

  .risk-item {
    grid-template-columns: 1fr;
  }

  .risk-meter {
    text-align: left;
  }
}

.session-timeout-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 28, 0.58);
  backdrop-filter: blur(6px);
}

.session-timeout-dialog {
  width: min(440px, 100%);
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 70px rgba(10, 24, 32, 0.24);
  color: #17242b;
}

.session-timeout-dialog h2 {
  margin: 0 0 10px;
  color: #173f46;
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0;
}

.session-timeout-dialog p {
  margin: 0;
  color: #5f6f76;
  line-height: 1.5;
}

.session-timeout-counter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 0;
  padding: 14px 16px;
  border: 1px solid #dce8e5;
  border-radius: 8px;
  background: #f6faf8;
}

.session-timeout-counter span {
  color: #5f6f76;
  font-size: 13px;
  font-weight: 750;
}

.session-timeout-counter strong {
  color: #b54708;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.session-timeout-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .session-timeout-dialog {
    padding: 22px;
  }

  .session-timeout-actions .btn {
    width: 100%;
  }
}

/* Saved reports contain their own styles: keep full photos in their preview too. */
.print-document .photo-grid img {
  max-width: 100%;
  object-fit: contain;
  object-position: center;
}

/* Keep this after the responsive navigation rules, including the collapsed rail. */
@media print {
  html,
  body {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body::before,
  .skip-link,
  .sidebar-backdrop,
  .session-timeout-backdrop {
    display: none !important;
  }

  .shell,
  .shell > .content,
  body.sidebar-collapsed .shell > .content,
  .shell > .content > .workspace {
    display: block !important;
    position: static !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    transition: none !important;
    background: #fff !important;
  }

  .print-document {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .print-document .report {
    width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .print-document .report-cover {
    min-height: 240mm;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .print-document .cover-footer {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* A room may span pages; each photo and its caption must stay together. */
  .print-document .room-section {
    break-inside: auto;
    page-break-inside: auto;
    overflow: visible;
  }

  .print-document .report h2,
  .print-document .report h3,
  .print-document .room-head {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Inline blocks paginate reliably in Safari, unlike a multi-page photo grid. */
  .print-document .photo-grid {
    display: block;
    font-size: 0;
    line-height: 0;
  }

  .print-document .photo-grid figure {
    display: inline-block;
    vertical-align: top;
    width: calc((100% - 4mm) / 2);
    max-width: 100%;
    margin: 0 4mm 4mm 0;
    font-size: 11px;
    line-height: 1.45;
    overflow: visible;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-document .photo-grid figure:nth-child(even) {
    margin-right: 0;
  }

  .print-document .photo-grid img {
    display: block;
    width: 100%;
    height: 60mm;
    max-height: 60mm;
    object-fit: contain;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .print-document .photo-grid figcaption {
    overflow-wrap: anywhere;
    break-before: avoid;
    page-break-before: avoid;
  }
}

/* Final UI/UX overrides kept last so they remain stable across the legacy cascade. */
@media screen {
  .content > .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(14px);
  }

  .topbar-user {
    border-radius: 14px;
  }

  .dashboard-kpi-card,
  .dashboard-card {
    border-radius: 14px;
  }

  .table-responsive {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }

  .workspace .page-head h1,
  .workspace .dashboard-hero h1 {
    letter-spacing: -.035em;
  }
}

@media screen and (max-width: 760px) {
  .workspace .table-responsive {
    border: 0;
    background: transparent;
  }

  .workspace .mobile-stack-table tr {
    border-radius: 14px;
  }
}
