:root {
  --bg: #f3f4ef;
  --panel: rgba(251, 252, 248, 0.94);
  --panel-strong: #fdfdf9;
  --line: #d9e0d9;
  --line-strong: #c5cec6;
  --text: #17211d;
  --muted: #66746d;
  --accent: #3f7363;
  --accent-soft: rgba(63, 115, 99, 0.1);
  --accent-strong: #15211d;
  --danger: #c2410c;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.045);
}

/* 2026-08 estimate home and detailed-entry refinement */
input[data-action="qty"],
[data-margin-input],
#adminMaterial,
#adminLabor {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[data-action="qty"]::-webkit-inner-spin-button,
input[data-action="qty"]::-webkit-outer-spin-button,
[data-margin-input]::-webkit-inner-spin-button,
[data-margin-input]::-webkit-outer-spin-button,
#adminMaterial::-webkit-inner-spin-button,
#adminMaterial::-webkit-outer-spin-button,
#adminLabor::-webkit-inner-spin-button,
#adminLabor::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

body[data-page="login"] .login-shell,
body[data-page="home"] .home-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  max-width: none;
  min-height: 100vh;
  min-height: 100svh;
}

body[data-page="login"] .login-layout {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
}

body[data-page="login"] .login-panel {
  align-self: stretch;
  width: 100%;
  min-height: 100%;
  padding: clamp(22px, 3vw, 48px);
}

body[data-page="login"] .login-panel > * {
  width: min(100%, 680px);
  margin-inline: auto;
}

.login-panel-brand {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 4px;
}

body[data-page="login"] .login-panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.login-account-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-self: end;
}

.login-account-stack .login-panel-brand {
  justify-content: center;
}

.login-panel-brand-logo {
  display: block;
  width: auto;
  max-width: min(240px, 52vw);
  height: 44px;
  object-fit: contain;
  object-position: left center;
}

.home-topbar {
  min-height: auto;
}

.home-account-actions,
.home-estimate-actions,
.home-admin-links,
.detail-estimate-tools,
.process-group-leading-actions,
.item-margin-bulk-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.home-account-actions .admin-session-badge,
.home-account-actions .home-admin-link,
.home-account-actions #homeLogoutButton {
  height: 38px;
  min-height: 38px;
  margin-top: 0;
  white-space: nowrap;
}

.home-account-actions #homeLogoutButton {
  width: auto;
  min-width: 0;
  padding-inline: 14px;
}

.home-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 18px;
  width: 100%;
  min-height: 0;
  padding-bottom: 32px;
}

.home-recent-panel {
  min-height: 100%;
}

.home-status-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 16px;
}

.home-status-filter {
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid #dce4e0;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.home-status-filter:hover {
  border-color: #a9bbb3;
  transform: translateY(-1px);
}

.home-status-filter:focus-visible {
  outline: 3px solid rgba(208, 119, 36, 0.24);
  outline-offset: 2px;
}

.home-status-filter span {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-status-filter strong {
  flex: 0 0 auto;
  font-size: 24px;
  line-height: 1;
}

.home-status-filter.is-active {
  border-color: #1f332b;
  box-shadow: 0 0 0 1px #1f332b, 0 9px 24px rgba(25, 45, 37, 0.08);
}

.home-status-filter.is-confirmed strong { color: #a56120; }
.home-status-filter.is-reservation_confirmed strong { color: #286b80; }
.home-status-filter.is-contract_completed strong { color: #21614a; }

.home-status-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}

.home-status-list-header strong {
  font-size: 15px;
}

.home-primary-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(230px, 0.85fr) minmax(230px, 0.85fr);
  gap: 14px;
}

.home-order-action {
  border-color: color-mix(in srgb, var(--accent, #245a43) 30%, var(--line));
}

.home-primary-action,
.home-secondary-action {
  display: grid;
  gap: 7px;
  min-height: 104px;
  align-content: center;
  padding: 22px 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-decoration: none;
}

.home-primary-action strong,
.home-secondary-action strong {
  font-size: 20px;
}

.home-primary-action span,
.home-secondary-action span {
  color: inherit;
  opacity: 0.78;
}

.home-secondary-action {
  background: #fff;
  color: var(--text);
}

.home-recent-list {
  display: grid;
  gap: 10px;
}

.home-estimate-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.home-estimate-main {
  display: grid;
  gap: 9px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.home-estimate-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-estimate-heading > strong {
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef3f0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.workflow-badge.is-confirmed { background: #fff1df; color: #8c551e; }
.workflow-badge.is-reservation_confirmed { background: #e4f1f5; color: #245f72; }
.workflow-badge.is-contract_completed { background: #e7f3ec; color: #245f4b; }

.home-estimate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 18px;
  color: var(--muted);
  font-size: 12px;
}

.home-estimate-meta b {
  color: var(--text);
  font-weight: 700;
}

.home-estimate-actions {
  justify-content: flex-end;
}

.button-link {
  display: inline-flex;
  width: auto;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.home-empty-state {
  display: grid;
  gap: 6px;
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}

.home-support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.home-cost-db-card,
.home-admin-card {
  display: grid;
  gap: 12px;
}

.home-admin-links {
  flex-wrap: wrap;
}

.home-admin-links a {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}

.detail-estimate-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-estimate-tools .compact-label {
  min-width: 116px;
}

body[data-page="detail"] .detail-estimate-table {
  min-width: 1160px;
}

.detail-estimate-table .line-order-column {
  position: sticky;
  left: 0;
  z-index: 5;
  width: 26px;
  min-width: 26px;
  max-width: 26px;
  padding-inline: 0;
  background: #fff;
}

.detail-estimate-table .line-select-column {
  left: 26px;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
}

.detail-estimate-table .line-item-column {
  left: 62px;
  width: 190px;
  min-width: 190px;
  max-width: 190px;
}

.detail-estimate-table .line-category-column {
  width: 120px;
  min-width: 120px;
  max-width: 120px;
}

.detail-estimate-table .line-spec-column {
  width: 145px;
  min-width: 145px;
  max-width: 145px;
}

.detail-estimate-table .line-unit-column {
  width: 34px;
  min-width: 34px;
  max-width: 34px;
}

.detail-estimate-table .line-quantity-column {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

.detail-estimate-table .line-quantity-column [data-action="qty"] {
  width: 42px;
  min-width: 42px;
}

.detail-estimate-table .line-unit-price-column {
  width: 62px;
  min-width: 62px;
  max-width: 62px;
}

.detail-estimate-table .line-amount-column {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
}

.detail-estimate-table .line-total-column {
  width: 80px;
  min-width: 80px;
  max-width: 80px;
}

.detail-estimate-table .line-remark-column {
  width: 155px;
  min-width: 155px;
}

.line-drag-handle {
  width: 28px;
  min-width: 28px;
  min-height: 34px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--accent);
  font-size: 22px;
}

.line-drag-handle:hover,
.line-drag-handle:focus-visible {
  border: 0;
  background: #eef3f0;
  box-shadow: none;
}

.line-group-head {
  grid-template-columns: auto minmax(170px, 1fr) auto auto;
}

.process-group-leading-actions .process-add-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
}

.process-group-leading-actions .process-memo-button {
  width: auto;
  min-height: 34px;
  padding-inline: 10px;
  font-size: 11px;
}

.process-group-leading-actions .process-copy-selected-button,
.process-group-footer-actions .process-copy-selected-button {
  width: auto;
  min-height: 34px;
  padding-inline: 10px;
  font-size: 11px;
}

.process-group-footer-row > td {
  padding: 8px 12px 14px;
  background: #f7f9f7;
}

.process-group-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.process-group-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.process-group-footer-actions .process-add-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
}

.process-copy-selected-button:disabled {
  opacity: 0.48;
}

.process-memo-row > td {
  background: #f9fbfa;
}

.process-memo-row .line-order-column,
.process-memo-row .line-select-column {
  padding-block: 8px;
}

.process-memo-cell {
  padding: 8px 12px 10px;
}

.process-memo-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.process-memo-editor label {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0;
}

.process-memo-editor textarea {
  width: 100%;
  min-height: 42px;
  resize: vertical;
}

.process-memo-card {
  background: #f9fbfa;
}

.process-memo-card .process-memo-editor label {
  grid-template-columns: 1fr;
}

.process-memo-delete {
  min-height: 38px;
}

.process-memo-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.process-memo-add,
.process-memo-delete {
  min-height: 38px;
  white-space: nowrap;
}

.line-card-totals {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.item-margin-bulk-tools {
  flex-wrap: wrap;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8faf8;
}

.item-margin-bulk-tools > strong {
  margin-right: auto;
}

.item-margin-bulk-tools .compact-label {
  width: 132px;
}

body[data-page="print"] .print-document-header {
  grid-template-columns: minmax(0, 1fr) 58mm;
  grid-template-rows: auto auto;
  gap: 2mm 4mm;
  align-items: end;
  padding-bottom: 2.6mm;
}

body[data-page="print"] .print-title-lockup {
  display: block;
  grid-column: 1;
  grid-row: 2;
}

body[data-page="print"] .print-title-lockup h1 {
  margin: 0;
  font-size: 24pt;
  letter-spacing: 0.02em;
}

body[data-page="print"] .print-header-right {
  display: contents;
}

body[data-page="print"] .print-logo-lockup {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 1;
  align-items: center;
  justify-self: end;
  justify-content: flex-end;
  gap: 2mm;
  width: auto;
  max-width: 100%;
}

body[data-page="print"] .print-logo-lockup .print-brand-mark {
  width: 22.68mm;
  height: 22.68mm;
  flex: 0 0 22.68mm;
}

body[data-page="print"] .print-logo-lockup .brand-mark-core {
  inset: 4.2mm;
  border-radius: 5.04mm;
}

body[data-page="print"] .print-logo-lockup .brand-mark-dot {
  width: 4.2mm;
  height: 4.2mm;
  right: 3.36mm;
  bottom: 3.36mm;
  box-shadow: 0 0 0 1.26mm rgba(255, 255, 255, 0.72);
}

body[data-page="print"] .print-logo-lockup .print-brand-mark.has-logo {
  width: 75.6mm;
  height: 22.68mm;
  flex-basis: 75.6mm;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body[data-page="print"] .print-logo-lockup .brand-logo-image {
  width: 100%;
  height: 100%;
  padding: 0;
  object-fit: contain;
  object-position: right center;
}

body[data-page="print"] .print-logo-lockup .print-brand-mark.has-logo + .print-brand-word {
  display: none;
}

body[data-page="print"] .print-logo-lockup .print-brand-word {
  font-size: 13.86pt;
}

body[data-page="print"] .print-document-meta {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  gap: 0.35mm;
}

body[data-page="print"] .print-document-meta > div {
  grid-template-columns: 17mm minmax(0, 1fr);
  gap: 1.5mm;
}

body[data-page="print"] .print-document-meta dt,
body[data-page="print"] .print-document-meta dd {
  line-height: 1.18;
  text-align: right;
}

body[data-page="print"] .print-note-title,
body[data-page="print"] .print-note-text {
  display: block;
}

body[data-page="print"] .print-note-title {
  margin-bottom: 0.6mm;
  font-weight: 800;
}

body[data-page="print"] .print-note-text {
  font-weight: 400;
}

@media screen and (max-width: 980px) {
  .home-primary-actions,
  .home-support-grid {
    grid-template-columns: 1fr;
  }

  .home-estimate-card {
    grid-template-columns: 1fr;
  }

  .home-status-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-estimate-actions {
    justify-content: flex-start;
  }

  .line-group-head {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .process-group-totals,
  .process-group-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media screen and (max-width: 640px) {
  .home-account-actions {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: stretch;
    gap: 6px;
  }

  .home-account-actions > * {
    min-height: 44px;
  }

  .home-account-actions .admin-session-badge,
  .home-account-actions .home-admin-link,
  .home-account-actions #homeLogoutButton {
    height: 44px;
    min-height: 44px;
  }

  .home-account-actions .admin-session-badge {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .home-account-actions .home-admin-link,
  .home-account-actions #homeLogoutButton {
    min-width: 0;
    margin-top: 0;
    padding-inline: 10px;
  }

  .home-estimate-meta,
  .home-estimate-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .home-estimate-actions a {
    width: 100%;
  }

  .home-status-list-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .detail-estimate-tools {
    width: 100%;
    justify-content: stretch;
  }

  .detail-estimate-tools > * {
    flex: 1 1 auto;
  }

  .line-card-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.62), transparent 28%),
    linear-gradient(180deg, #f7f8f3 0%, #eef1ea 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary {
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell,
.print-shell {
  min-height: 100vh;
  min-height: 100svh;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-block {
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, #fcfffd, #e8f2ec);
  border: 1px solid rgba(63, 115, 99, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.brand-mark-core,
.brand-mark-dot {
  position: absolute;
  display: block;
  transition: opacity 0.2s ease;
}

.brand-mark-core {
  inset: 13px;
  border-radius: 14px;
  background: linear-gradient(150deg, #1f312b, #4f7f70);
}

.brand-mark-dot {
  width: 12px;
  height: 12px;
  right: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: #d7efe5;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.72);
}

.brand-logo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 8px;
  object-fit: contain;
}

.brand-mark.has-logo {
  background: #fff;
}

.brand-mark.has-logo .brand-mark-core,
.brand-mark.has-logo .brand-mark-dot {
  opacity: 0;
}

.header-controls {
  display: grid;
  gap: 14px;
  justify-items: end;
  min-width: 0;
}

.page-nav,
.topbar-actions,
.action-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-nav {
  justify-content: flex-end;
}

.nav-chip,
.button-link,
button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.nav-chip,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
}

.nav-chip:hover,
.button-link:hover,
button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgba(21, 33, 29, 0.08);
}

.nav-chip.is-active {
  color: #fff;
  background: linear-gradient(135deg, #1e352d, #4d7d6d);
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(21, 33, 29, 0.12);
}

.topbar-actions {
  justify-content: flex-end;
}

.admin-session-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-session-badge {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(45, 85, 71, 0.16);
  background: rgba(232, 242, 236, 0.92);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.admin-account-link {
  text-decoration: none;
  cursor: pointer;
}

.admin-account-link:hover {
  border-color: var(--line-strong);
  background: rgba(220, 237, 227, 0.96);
}

.admin-account-link:focus-visible {
  outline: 3px solid rgba(45, 85, 71, 0.3);
  outline-offset: 2px;
}

.admin-logout-button {
  white-space: nowrap;
}

.admin-session-tools .admin-logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 0 14px;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.hero-panel,
.panel,
.table-wrap,
.summary-card,
.metric,
.saved-card,
.line-card,
.print-sheet {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 14px;
  padding: 20px;
  border-radius: 18px;
  margin-bottom: 16px;
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 10px;
}

.hero-copy h2 {
  font-size: 34px;
  letter-spacing: -0.05em;
}

.hero-total-card {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(160deg, #16231f, #486f62);
  color: #fff;
  box-shadow: none;
}

.hero-total-card span,
.hero-total-card em {
  font-style: normal;
  opacity: 0.92;
}

.hero-total-card strong {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.hero-meta-grid,
.print-meta-grid {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
}

.hero-meta-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.print-meta-grid {
  grid-template-columns: 1fr;
}

.hero-meta-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
}

.hero-meta-card span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
}

.hero-meta-card strong {
  display: block;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.hero-meta-accent {
  background: linear-gradient(180deg, rgba(63, 115, 99, 0.08), rgba(253, 253, 249, 0.88));
}

.hero-terms-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(26, 76, 71, 0.1);
  background: rgba(255, 255, 255, 0.68);
}

.hero-terms-copy span,
.hero-remark-field {
  font-size: 12px;
  color: var(--muted);
}

.hero-terms-copy ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.65;
  color: var(--ink);
}

.hero-remark-field {
  margin-top: 0;
}

.hero-remark-field textarea {
  min-height: 86px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}

.summary-layout {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.main-column,
.side-column {
  min-width: 0;
}

.admin-single-layout {
  display: grid;
  gap: 14px;
}

.admin-settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  gap: 14px;
  align-items: start;
}

.admin-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border-radius: 14px;
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.panel {
  padding: 16px;
  border-radius: 18px;
  margin-bottom: 14px;
}

.panel-header,
.inline-controls {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: end;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header.compact {
  margin-bottom: 12px;
}

label {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.compact-label,
.form-grid label,
.line-card-field {
  margin-top: 0;
}

input,
select,
textarea,
button {
  width: 100%;
}

input,
select,
textarea {
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(253, 253, 249, 0.98);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(63, 115, 99, 0.42);
  box-shadow: 0 0 0 4px rgba(63, 115, 99, 0.12);
}

button {
  margin-top: 12px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 600;
}

button.accent,
.button-link.accent-link {
  color: #fff;
  background: linear-gradient(135deg, #1e342d, #4e7d6e);
  border-color: transparent;
  box-shadow: 0 14px 26px rgba(21, 33, 29, 0.16);
}

button.ghost,
.button-link {
  background: rgba(255, 255, 255, 0.76);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.table-wrap,
.print-table-wrap {
  border-radius: 14px;
}

.table-wrap {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.print-table-wrap {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.cost-db-table th,
.cost-db-table td {
  white-space: nowrap;
}

.cost-db-table td:nth-child(3),
.cost-db-table td:nth-child(4),
.cost-db-table td:nth-child(5),
.cost-db-table td:last-child {
  white-space: normal;
}

.cost-db-table tr.is-cost-item-inactive > td {
  background: #f5f4f1;
  color: var(--muted);
}

.cost-item-status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.cost-item-status.is-active {
  color: #2f6b4f;
  border: 1px solid rgba(47, 107, 79, 0.22);
  background: #eaf6ef;
}

.cost-item-status.is-inactive {
  color: #6b6258;
  border: 1px solid rgba(107, 98, 88, 0.22);
  background: #ebe8e3;
}

.admin-nav-menu {
  position: relative;
  display: inline-flex;
}

.admin-nav-trigger {
  width: auto;
  min-height: 42px;
  margin: 0;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
}

.home-admin-menu .home-admin-link {
  width: auto;
  margin: 0;
}

.admin-nav-dropdown {
  position: fixed;
  z-index: 120;
  display: grid;
  width: max-content;
  min-width: 210px;
  overflow: hidden;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  box-shadow: 0 18px 46px rgba(21, 33, 29, 0.18);
}

.admin-nav-dropdown a {
  display: flex;
  min-height: 42px;
  align-items: center;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.admin-nav-dropdown a:hover,
.admin-nav-dropdown a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
  outline: none;
}

.cost-db-inline-cost-cell {
  min-width: 132px;
}

.cost-db-inline-cost-input {
  width: 124px;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 9px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cost-db-inline-cost-input[aria-invalid="true"] {
  border-color: #b64232;
  background: #fff5f2;
}

.cost-db-row-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.cost-db-row-actions button {
  min-width: 56px;
  margin: 0;
}

.vendor-quote-toggle {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid rgba(185, 117, 39, 0.28);
  border-radius: 14px;
  background: rgba(255, 249, 235, 0.78);
}

.vendor-quote-toggle input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 1px 0 0;
}

.vendor-quote-toggle strong,
.vendor-quote-toggle small {
  display: block;
}

.vendor-quote-toggle strong {
  color: var(--text);
  font-size: 13px;
}

.vendor-quote-toggle small {
  margin-top: 4px;
  line-height: 1.45;
}

.pricing-type-field {
  display: grid;
  gap: 6px;
  padding: 13px 14px;
  border: 1px solid rgba(185, 117, 39, 0.28);
  border-radius: 14px;
  background: rgba(255, 249, 235, 0.78);
}

.pricing-type-field select {
  margin-top: 0;
}

.pricing-type-field small {
  color: var(--muted);
  line-height: 1.45;
}

.vendor-quote-badge {
  display: inline-flex;
  width: fit-content;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.vendor-quote-badge.is-pending {
  color: #80551c;
  border: 1px solid rgba(185, 117, 39, 0.28);
  background: #fff4d8;
}

.vendor-quote-badge.is-complete {
  color: #2f6b4f;
  border: 1px solid rgba(47, 107, 79, 0.22);
  background: #eaf6ef;
}

.line-item-cell {
  display: grid;
  gap: 7px;
}

.vendor-quote-guide {
  margin: -2px 0 13px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 249, 235, 0.72);
  line-height: 1.55;
}

.project-quote-status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.project-quote-status-row .vendor-quote-guide {
  flex: 1 1 auto;
  margin: 0;
}

.project-quote-pending-count {
  display: inline-flex;
  flex: 0 0 auto;
  min-height: 38px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(47, 107, 79, 0.2);
  border-radius: 999px;
  background: #eaf6ef;
  color: #2f6b4f;
  font-size: 12px;
  white-space: nowrap;
}

.project-quote-pending-count.has-pending {
  border-color: rgba(185, 117, 39, 0.32);
  background: #fff4d8;
  color: #80551c;
}

.line-card-title {
  display: grid;
  gap: 6px;
}

.vendor-quote-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(185, 117, 39, 0.26);
  border-radius: 14px;
  background: rgba(255, 249, 235, 0.72);
}

.vendor-quote-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  color: var(--muted);
  font-size: 11px;
}

.vendor-quote-editor .vendor-cost-input {
  text-align: right;
}

.project-cost-table-row > td {
  padding: 8px 10px 14px;
  background: #fffdf8;
}

.project-cost-editor.is-compact {
  max-width: 920px;
  margin: 0;
}

.project-cost-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 9px;
}

.project-cost-field {
  min-width: 0;
  margin: 0;
  color: #5d5a51;
  font-size: 11px;
  font-weight: 700;
}

.project-cost-field input,
.project-cost-field textarea {
  min-height: 44px;
  margin-top: 5px;
  padding: 9px 10px;
  font-size: 13px;
}

.project-cost-reason-field {
  grid-column: span 2;
}

.project-cost-field [readonly] {
  cursor: not-allowed;
  background: #f1f2ef;
  color: #676e69;
}

.project-cost-permission-guide {
  margin: 0;
  color: #8a5f0f;
  font-size: 11px;
  font-weight: 700;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #edf1ee;
  vertical-align: top;
  font-size: 12px;
}

th {
  background: #f7faf8;
  color: #42504a;
  text-align: left;
  font-weight: 700;
}

td input,
td select,
td textarea,
td button {
  margin-top: 0;
}

.short-button {
  width: auto;
  min-width: 124px;
}

.summary-card,
.saved-card {
  border-radius: 14px;
  padding: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed #dce5df;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row.total {
  color: var(--accent);
  font-weight: 700;
}

.build-up-card {
  display: grid;
  gap: 10px;
}

.build-up-list {
  display: grid;
  gap: 8px;
}

.build-up-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 246, 0.92);
}

.build-up-copy {
  min-width: 0;
}

.build-up-copy strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.45;
}

.line-group-row td {
  padding: 12px 10px;
  background: #f7faf8;
}

.line-group-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.line-card-group {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.line-card-group:last-child {
  margin-bottom: 0;
}

.saved-title {
  margin-bottom: 8px;
  font-size: 17px;
}

.saved-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.saved-search-label {
  width: min(100%, 620px);
  margin-top: 0;
}

.saved-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.saved-filter-grid label {
  min-width: 0;
  margin-top: 0;
}

.saved-filter-grid input,
.saved-filter-grid select,
.saved-filter-grid button {
  min-height: 44px;
}

.saved-filter-grid button {
  align-self: end;
}

@media screen and (max-width: 860px) {
  .saved-filter-grid .saved-filter-desktop {
    display: none;
  }
}

.saved-sort-note {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 44px;
}

.saved-feedback {
  min-height: 18px;
  margin-bottom: 12px;
}

.saved-feedback[data-tone="success"] {
  color: #1b6d56;
  font-weight: 700;
}

.saved-feedback[data-tone="info"] {
  color: #225c87;
  font-weight: 700;
}

.saved-feedback[data-tone="error"] {
  color: #a43125;
  font-weight: 700;
}

.saved-list-state {
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  text-align: center;
}

.saved-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.saved-pagination:empty {
  display: none;
}

.saved-pagination button {
  min-width: 72px;
  min-height: 42px;
}

.saved-page-current {
  min-width: 88px;
  text-align: center;
}

.saved-card + .saved-card {
  margin-top: 12px;
}

.saved-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.saved-card-head .eyebrow {
  margin-bottom: 4px;
}

.saved-total {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(63, 115, 99, 0.1);
  color: var(--accent-strong);
  font-size: 13px;
  white-space: nowrap;
}

.saved-meta {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.saved-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.saved-meta-grid div {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(248, 250, 246, 0.92);
  border: 1px solid rgba(26, 33, 42, 0.08);
}

.saved-meta-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.saved-meta-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.saved-actions {
  display: flex;
  gap: 8px;
}

.saved-actions .danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.25);
}

.admin-shortcuts .button-link {
  flex: 1 1 160px;
}

.admin-shortcuts-hero .button-link {
  min-height: 48px;
  font-size: 14px;
}

.settings-divider {
  margin: 18px 0;
  border-top: 1px solid var(--line);
}

.quotation-term-list {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.quotation-term-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(248, 250, 246, 0.88);
}

.quotation-term-fields {
  display: grid;
  grid-template-columns: minmax(150px, 0.35fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.quotation-term-row textarea {
  min-height: 68px;
}

.quotation-term-row .short-button {
  margin-top: 0;
}

.inner-panel-header {
  margin-bottom: 10px;
}

.inner-panel-header h3 {
  font-size: 18px;
  letter-spacing: -0.03em;
}

.saved-actions button {
  margin-top: 0;
}

.cost-item-list {
  display: grid;
  gap: 10px;
}

.db-process-block {
  margin-bottom: 18px;
}

.db-process-block:last-child {
  margin-bottom: 0;
}

.local-cost-db-panel .summary-grid.compact {
  margin: 12px 0;
}

.horizontal-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cost-item-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.cost-item-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.cost-item-category {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.cost-item-name {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.cost-item-meta,
.cost-item-remark {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.cost-item-prices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.panel-divider {
  height: 1px;
  margin: 18px 0 4px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.panel-note {
  margin-bottom: 14px;
  line-height: 1.55;
}

.user-manager-feedback {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(45, 85, 71, 0.16);
  background: rgba(232, 242, 236, 0.92);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.user-manager-feedback[data-tone="warning"] {
  border-color: rgba(154, 107, 16, 0.24);
  background: rgba(255, 247, 226, 0.95);
  color: #8a5f0f;
}

.user-manager-feedback[data-tone="error"] {
  border-color: rgba(180, 35, 24, 0.22);
  background: rgba(255, 235, 232, 0.95);
  color: #b42318;
}

.approval-request-panel {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(154, 107, 16, 0.18);
  background: rgba(255, 247, 226, 0.72);
}

.approval-request-head,
.approval-request-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.approval-request-head {
  margin-bottom: 12px;
}

.approval-request-head h3 {
  font-size: 18px;
  letter-spacing: -0.03em;
}

.approval-request-list {
  display: grid;
  gap: 10px;
}

.approval-request-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(154, 107, 16, 0.16);
  background: rgba(255, 255, 255, 0.82);
}

.approval-request-card div {
  min-width: 0;
}

.approval-request-card strong,
.approval-request-card span {
  display: block;
}

.approval-request-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.approval-request-card .short-button {
  width: auto;
  min-width: 96px;
  margin-top: 0;
}

.approval-request-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.user-management-table td {
  vertical-align: middle;
}

.user-management-table {
  min-width: 1040px;
}

.user-identity,
.user-control-cell,
.user-actions,
.user-guide-list {
  display: grid;
  gap: 6px;
}

.user-actions {
  grid-template-columns: minmax(120px, max-content);
  align-items: center;
}

.user-actions .short-button {
  min-width: 120px;
}

.short-button.danger,
button.danger {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.25);
}

.user-pill,
.user-status-pill,
.user-lock-note {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.user-pill,
.user-status-pill {
  padding: 5px 9px;
  border: 1px solid rgba(45, 85, 71, 0.14);
  background: rgba(248, 250, 246, 0.98);
  color: var(--accent);
}

.user-pill.is-owner {
  background: rgba(232, 242, 236, 0.96);
}

.user-status-pill.is-pending {
  background: rgba(255, 247, 226, 0.96);
  color: #8a5f0f;
}

.user-status-pill.is-active {
  background: rgba(232, 242, 236, 0.96);
}

.user-status-pill.is-blocked {
  background: rgba(255, 235, 232, 0.96);
  color: #b42318;
}

.user-status-pill.is-rejected {
  background: rgba(245, 238, 232, 0.96);
  color: #7c4a25;
}

.user-control-cell select:not(:disabled) {
  cursor: pointer;
  background-color: #fff;
}

.project-cost-permission-cell {
  display: grid;
  min-width: 170px;
  gap: 6px;
}

.user-pill.is-enabled {
  border-color: rgba(47, 107, 79, 0.22);
  background: #eaf6ef;
  color: #2f6b4f;
}

.project-cost-permission-toggle {
  display: inline-flex;
  width: fit-content;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0 11px;
  border-color: rgba(103, 110, 105, 0.24);
  background: #f1f2ef;
  color: #676e69;
}

.project-cost-permission-toggle > span {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #a8afab;
}

.project-cost-permission-toggle > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.15s ease;
}

.project-cost-permission-toggle.is-enabled {
  border-color: rgba(47, 107, 79, 0.26);
  background: #eaf6ef;
  color: #2f6b4f;
}

.project-cost-permission-toggle.is-enabled > span {
  background: #3f7363;
}

.project-cost-permission-toggle.is-enabled > span::after {
  transform: translateX(14px);
}

.user-lock-note,
.user-helper {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.user-guide-list {
  margin-bottom: 14px;
}

.user-guide-list article {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248, 250, 246, 0.98);
  border: 1px solid var(--line);
}

.user-guide-list strong,
.user-guide-list span {
  display: block;
}

.audit-filter-grid {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(140px, 0.7fr) minmax(240px, 1.6fr);
  gap: 12px;
  margin: 16px 0 4px;
}

.audit-filter-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.audit-log-table {
  min-width: 980px;
}

.audit-log-table th,
.audit-log-table td {
  vertical-align: top;
}

.audit-detail summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.audit-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.audit-compare section {
  min-width: 0;
}

.audit-compare pre {
  max-height: 320px;
  overflow: auto;
  margin: 7px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f3ed;
  color: var(--ink);
  font-size: 0.72rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 780px) {
  .audit-filter-grid,
  .audit-compare {
    grid-template-columns: 1fr;
  }
}

.user-guide-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.cost-item-price {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(248, 250, 246, 0.98);
  border: 1px solid var(--line);
}

.cost-item-price span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.cost-item-price strong {
  font-size: 14px;
}

.adjustment-manager {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.discount-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.discount-calculation-note {
  margin-top: 8px;
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  .discount-settings-grid {
    grid-template-columns: 1fr;
  }
}

.adjustment-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(247, 249, 245, 0.94);
}

.adjustment-item.off {
  opacity: 0.7;
}

.adjustment-title {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 700;
}

.adjustment-desc {
  font-size: 12px;
  color: var(--muted);
}

.adjustment-toggle {
  width: auto;
  min-width: 84px;
  margin-top: 0;
  min-height: 40px;
  padding: 0 14px;
  font-size: 12px;
}

.process-margin-list {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.margin-accordion {
  display: grid;
  gap: 12px;
}

.margin-accordion-section {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
}

.margin-accordion-trigger {
  display: grid;
  width: 100%;
  min-height: 92px;
  margin: 0;
  padding: 18px 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  box-shadow: none;
}

.margin-accordion-trigger:hover,
.margin-accordion-trigger[aria-expanded="true"] {
  background: rgba(247, 249, 245, 0.96);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.margin-accordion-trigger:focus-visible {
  outline: 3px solid rgba(45, 85, 71, 0.32);
  outline-offset: -4px;
}

.margin-accordion-trigger > span:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.margin-accordion-trigger .eyebrow {
  margin: 0;
}

.margin-accordion-trigger strong {
  font-size: 21px;
  letter-spacing: -0.035em;
}

.margin-accordion-trigger > .muted {
  margin-top: 5px;
  font-size: 13px;
  font-weight: 500;
}

.margin-accordion-panel {
  padding: 4px 22px 22px;
  border-top: 1px solid var(--line);
}

.margin-global-batch-card {
  margin: 18px 0;
  background: rgba(247, 249, 245, 0.92);
}

.process-margin-card {
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
}

.process-margin-head,
.process-margin-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.process-margin-head {
  margin-bottom: 12px;
}

.process-margin-head h3 {
  font-size: 19px;
  letter-spacing: -0.03em;
}

.process-margin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.process-margin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.process-margin-button {
  width: auto;
  min-width: 180px;
  margin-top: 0;
}

.process-margin-savebar,
.item-margin-savebar,
.margin-action-row,
.item-margin-feedback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.process-margin-savebar,
.item-margin-savebar {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.process-margin-savebar p,
.item-margin-savebar p {
  margin: 0;
  font-weight: 700;
}

.margin-action-row {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.margin-action-row button,
.margin-undo-button {
  width: auto;
  margin-top: 0;
}

.margin-change-preview {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(247, 249, 245, 0.94);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.65;
}

.margin-change-preview strong {
  color: var(--accent-strong);
}

.process-margin-card.has-staged-change {
  border-color: rgba(185, 117, 39, 0.45);
  box-shadow: inset 3px 0 0 var(--accent);
}

.process-margin-card.has-invalid-change,
[data-margin-input][aria-invalid="true"] {
  border-color: var(--danger);
}

.item-margin-feedback {
  align-items: flex-start;
  margin-bottom: 12px;
}

.item-margin-feedback .item-margin-status {
  flex: 1;
  margin-bottom: 0;
}

.margin-undo-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 11px;
  white-space: nowrap;
}

.item-margin-table tr.has-save-error {
  background: rgba(179, 54, 54, 0.05);
}

.item-margin-table tr.has-staged-change {
  background: rgba(185, 117, 39, 0.07);
  box-shadow: inset 3px 0 0 var(--accent);
}

.item-margin-table tr.has-invalid-change {
  background: rgba(179, 54, 54, 0.05);
}

.item-margin-toolbar {
  display: grid;
  grid-template-columns: minmax(160px, 0.65fr) minmax(150px, 0.5fr) minmax(230px, 1.35fr);
  gap: 12px;
  margin: 16px 0 10px;
}

.item-margin-status {
  min-height: 22px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.item-margin-status[data-tone="pending"] {
  color: var(--accent-strong);
}

.item-margin-status[data-tone="success"] {
  color: #2f6b4f;
}

.item-margin-status[data-tone="error"] {
  color: var(--danger);
}

.item-margin-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.item-margin-table {
  min-width: 900px;
}

.item-margin-table th:nth-last-child(-n + 3),
.item-margin-table td:nth-last-child(-n + 3) {
  text-align: center;
}

.item-margin-name {
  display: block;
  min-width: 150px;
}

.item-margin-input {
  width: 112px;
  min-height: 42px;
  padding: 8px 10px;
  text-align: right;
}

.item-margin-basis {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(102, 116, 109, 0.09);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.item-margin-basis.is-override {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.item-margin-basis-group {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.item-margin-reset {
  width: auto;
  min-width: 92px;
  min-height: 34px;
  margin: 6px 0 0;
  padding: 0 10px;
  font-size: 11px;
}

.item-margin-empty {
  padding: 18px 0 4px;
  text-align: center;
}

.brand-preview {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(247, 249, 245, 0.94);
}

.brand-preview-mark {
  position: relative;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  place-items: center;
}

.preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 10px;
  object-fit: contain;
}

.brand-preview-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: linear-gradient(145deg, #fcfffd, #ebf4ef);
}

[hidden],
.brand-preview-fallback[hidden],
.brand-logo-image[hidden] {
  display: none !important;
}

.inline-settings-card {
  margin: 14px 0 6px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(247, 249, 245, 0.92);
}

.brand-preview-copy {
  min-width: 0;
}

.brand-preview-copy strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.empty-row {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.danger {
  color: var(--danger);
}

.sticky-panel {
  position: static;
}

.mobile-line-cards,
.mobile-total-bar {
  display: none;
}

.detail-scroll-hint {
  display: none;
}

.detail-scroll-hint[hidden] {
  display: none !important;
}

.detail-table-wrap {
  position: relative;
  isolation: isolate;
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
  touch-action: pan-x pan-y pinch-zoom;
}

.detail-estimate-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: inset 0 -1px 0 #dfe6e1;
}

.detail-estimate-table .line-item-column {
  position: sticky;
  left: 42px;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 #dfe6e1, 8px 0 14px rgba(15, 23, 42, 0.035);
}

.detail-estimate-table thead .line-item-column {
  z-index: 5;
  background: #f7faf8;
}

.detail-estimate-table .line-item-cell {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.detail-estimate-table th:nth-child(n + 4):nth-child(-n + 8),
.detail-estimate-table td:nth-child(n + 4):nth-child(-n + 8) {
  white-space: nowrap;
}

.line-card {
  padding: 18px;
  border-radius: 26px;
}

.line-card.empty-card {
  text-align: center;
}

.line-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.line-card-category {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.line-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.line-card-field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.line-card-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.summary-chip {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(247, 250, 248, 0.98);
}

.summary-chip span,
.mobile-total-copy p {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.summary-chip strong,
.mobile-total-copy strong {
  font-size: 14px;
}

.summary-chip.strong {
  border-color: rgba(63, 115, 99, 0.2);
  background: rgba(63, 115, 99, 0.09);
}

.import-feedback {
  display: grid;
  gap: 10px;
}

.import-feedback p {
  margin: 0;
}

.import-feedback-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.import-feedback-list li + li {
  margin-top: 4px;
}

.import-feedback-error {
  color: #b04a3a;
}

.import-feedback-ok {
  color: #2c6f57;
}

.mobile-total-bar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-radius: 24px;
  background: rgba(20, 34, 29, 0.94);
  box-shadow: 0 24px 40px rgba(15, 23, 42, 0.22);
}

.mobile-total-copy {
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.09);
}

.mobile-total-copy p,
.mobile-total-copy strong {
  color: #fff;
}

.print-shell {
  max-width: 980px;
  margin: 0 auto;
}

.print-sheet {
  margin-bottom: 18px;
  padding: 28px;
  border-radius: 30px;
}

.print-brand {
  margin-bottom: 18px;
}

.print-document-hero {
  margin-bottom: 18px;
}

.print-total-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(26, 76, 71, 0.1), rgba(227, 242, 229, 0.72)),
    rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(26, 76, 71, 0.14);
}

.print-total-copy h2 {
  margin: 4px 0 8px;
  font-size: 38px;
  letter-spacing: -0.05em;
}

.print-total-amount {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
}

.print-total-amount span {
  font-size: 13px;
  color: var(--muted);
}

.print-total-amount strong {
  margin-top: 8px;
  font-size: 32px;
  letter-spacing: -0.04em;
  color: var(--ink);
}

.print-section-header {
  margin-bottom: 18px;
}

.print-process-summary-stack {
  display: grid;
  gap: 12px;
}

.print-terms-section {
  margin-top: 18px;
}

.print-terms-card {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.print-terms-head {
  margin-bottom: 10px;
}

.print-terms-head h2 {
  font-size: 20px;
  letter-spacing: -0.03em;
}

.print-terms-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.75;
}

.print-company-note {
  margin-top: 12px;
}

.print-remark-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(26, 76, 71, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.print-remark-box span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.print-remark-box p {
  margin: 0;
  line-height: 1.65;
}

.print-meta-grid {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.print-info-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(116px, 0.24fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  overflow: hidden;
  padding: 18px;
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(247, 250, 248, 0.8)),
    rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(26, 76, 71, 0.12);
}

.print-info-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, rgba(63, 115, 99, 0.72), rgba(63, 115, 99, 0.16));
}

.print-info-card h3 {
  position: relative;
  margin: 4px 0 0;
  padding-left: 2px;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.print-info-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}

.print-info-grid div {
  min-width: 0;
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(26, 33, 42, 0.06);
}

.print-info-grid span {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.print-info-grid strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.print-company-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.print-company-card h3 {
  font-size: 22px;
  letter-spacing: -0.03em;
}

.print-company-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.print-company-grid span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--muted);
}

.print-company-grid strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
}

.print-detail-group {
  margin-top: 18px;
}

.print-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.print-detail-head h3 {
  font-size: 24px;
  letter-spacing: -0.03em;
}

@media screen and (max-width: 1180px) {
  .saved-filter-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .layout,
  .summary-layout,
  .admin-settings-grid,
  .admin-menu-grid,
  .hero-terms-panel,
  .metrics,
  .form-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header,
  .inline-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .header-controls {
    justify-items: stretch;
  }

  .page-nav,
  .topbar-actions {
    justify-content: flex-start;
  }

  .hero-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-scroll-hint {
    display: flex;
    width: fit-content;
    max-width: 100%;
    min-height: 36px;
    align-items: center;
    gap: 7px;
    margin: 0 0 9px;
    padding: 8px 11px;
    border: 1px solid rgba(63, 115, 99, 0.18);
    border-radius: 11px;
    background: rgba(239, 247, 242, 0.94);
    color: #355e51;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
  }

  .detail-scroll-hint::before {
    content: "↔";
    flex: 0 0 auto;
    font-size: 16px;
  }

  .detail-table-wrap {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
    overscroll-behavior-x: contain;
  }

  .detail-estimate-table {
    min-width: 1040px;
  }

  .detail-estimate-table .line-item-column {
    min-width: 210px;
    max-width: 260px;
  }

  .detail-estimate-table input[type="number"],
  .detail-estimate-table .vendor-cost-input {
    min-width: 96px;
    min-height: 44px;
  }

  .detail-estimate-table select,
  .detail-estimate-table .line-drag-handle {
    min-height: 44px;
  }

  .detail-estimate-table .line-drag-handle {
    min-width: 40px;
    margin: 0;
    padding-inline: 0;
  }
}

@media screen and (max-width: 860px) {
  .process-margin-savebar,
  .item-margin-feedback {
    align-items: stretch;
    flex-direction: column;
  }

  .process-margin-savebar .margin-action-row,
  .item-margin-feedback .margin-undo-button {
    width: 100%;
  }

  .process-margin-savebar .margin-action-row button {
    flex: 1;
  }

  body[data-page="detail"] {
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
  }

  .shell,
  .print-shell {
    padding: 12px;
  }

  .topbar,
  .panel,
  .hero-panel,
  .print-sheet {
    padding: 14px;
    border-radius: 14px;
  }

  h1 {
    font-size: 26px;
  }

  h2,
  .hero-copy h2 {
    font-size: 20px;
  }

  .page-nav,
  .topbar-actions,
  .action-stack,
  .hero-meta-grid,
  .print-meta-grid,
  .quotation-term-row,
  .quotation-term-fields,
  .print-total-hero,
  .print-company-card,
  .print-company-grid,
  .form-grid,
  .metrics,
  .line-card-grid,
  .line-card-totals,
  .cost-item-prices,
  .process-margin-grid,
  .item-margin-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .print-info-grid {
    grid-template-columns: 1fr;
  }

  .print-info-card {
    grid-template-columns: 1fr;
  }

  .saved-toolbar,
  .saved-meta-grid,
  .saved-card-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .saved-sort-note {
    justify-content: flex-start;
    min-height: auto;
  }

  .saved-total {
    justify-self: start;
  }

  .page-nav,
  .topbar-actions,
  .action-stack {
    gap: 8px;
  }

  body[data-page="detail"] .detail-sheet-section > .table-wrap {
    display: block;
  }

  body[data-page="detail"] .mobile-line-cards {
    display: none;
  }

  .mobile-total-bar {
    display: grid;
  }

  .hero-total-card strong {
    font-size: 34px;
  }
}

@media screen and (min-width: 861px) and (max-width: 1024px) {
  body[data-page="detail"] {
    padding-bottom: calc(210px + env(safe-area-inset-bottom));
  }

  body[data-page="detail"] .mobile-total-bar {
    display: grid;
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  body[data-page="detail"] .mobile-total-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="detail"] .mobile-total-actions button {
    min-height: 44px;
    margin: 0;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
  }

  body[data-page="detail"] .mobile-total-actions button.accent {
    background: #fff;
    color: #1e342d;
  }

  body[data-page="detail"] #estimateSaveStatus {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: calc(164px + env(safe-area-inset-bottom));
    left: max(14px, env(safe-area-inset-left));
    z-index: 21;
    width: auto;
    min-height: 40px;
    margin: 0;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.15);
  }

  body[data-page="detail"]:has(input:focus, select:focus, textarea:focus) .mobile-total-bar,
  body[data-page="detail"]:has(input:focus, select:focus, textarea:focus) #estimateSaveStatus {
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 36px));
  }
}

.login-shell {
  min-height: 100vh;
}

.login-topbar {
  margin-bottom: 20px;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.login-panel,
.auth-guide-panel {
  align-self: start;
}

.auth-message {
  margin-bottom: 16px;
}

.auth-message[data-tone="warning"] {
  color: #9a6b10;
}

.auth-message[data-tone="error"] {
  color: #b42318;
}

.password-change-message {
  margin-top: 14px;
  margin-bottom: 0;
  padding: 11px 12px;
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 10px;
  background: rgba(180, 35, 24, 0.07);
  font-weight: 700;
}

input[aria-invalid="true"] {
  border-color: #b42318;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.1);
}

.email-login-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(26, 33, 42, 0.1);
}

.registration-details {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(26, 33, 42, 0.1);
}

.registration-details summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}

.registration-details .email-login-form {
  margin-top: 12px;
  padding-top: 0;
  border-top: 0;
}

.primary-login-form {
  padding-top: 0;
  border-top: 0;
}

.domain-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
}

.domain-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.domain-input-group input {
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.domain-input-group input:focus {
  outline: 0;
  box-shadow: none;
}

.domain-input-group strong {
  padding: 0 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.login-help {
  margin-top: 14px;
  line-height: 1.65;
}

.single-column {
  grid-template-columns: 1fr;
}

.auth-guide-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.admin-session-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(34, 121, 94, 0.1);
  color: #1b6d56;
  font-size: 12px;
  font-weight: 700;
}

.pending-approval-link {
  text-decoration: none;
  background: rgba(255, 247, 226, 0.95);
  color: #8a5f0f;
}

@media screen and (max-width: 920px) {
  .login-layout {
    grid-template-columns: 1fr;
  }
}

body[data-page="print"] {
  background: #fff;
}

body[data-page="print"] .print-sheet {
  background: #fff;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body[data-page="print"] .print-total-hero,
body[data-page="print"] .print-total-amount,
body[data-page="print"] .print-terms-card,
body[data-page="print"] .print-remark-box,
body[data-page="print"] .print-info-card,
body[data-page="print"] .print-info-grid div,
body[data-page="print"] .summary-card,
body[data-page="print"] table,
body[data-page="print"] th {
  background: #fff;
  box-shadow: none;
}

body[data-page="print"] .print-info-card::before {
  display: none;
}

body[data-page="print"] .print-shell {
  max-width: 794px;
  min-height: 0;
  padding: 0 14px 14px;
}

body[data-page="print"] .print-sheet {
  margin: 14px 0 16px;
  padding: 20px;
  border-radius: 26px;
}

body[data-page="print"] .print-brand,
body[data-page="print"] .print-document-hero {
  margin-bottom: 14px;
}

body[data-page="print"] .print-total-hero {
  grid-template-columns: minmax(0, 1.08fr) minmax(260px, 0.92fr);
  gap: 14px;
  padding: 18px;
  border-radius: 22px;
}

body[data-page="print"] .print-total-copy h2 {
  margin: 2px 0 6px;
  font-size: 34px;
}

body[data-page="print"] .print-total-amount {
  padding: 15px;
  border-radius: 18px;
}

body[data-page="print"] .print-total-amount strong {
  margin-top: 6px;
  font-size: 30px;
}

body[data-page="print"] .print-meta-grid {
  grid-template-columns: 1fr;
  gap: 10px;
}

body[data-page="print"] .print-info-card {
  padding: 14px;
  border-radius: 18px;
}

body[data-page="print"] .print-info-card h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

body[data-page="print"] .print-info-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

body[data-page="print"] .print-info-grid div {
  padding: 8px 9px;
  border-radius: 12px;
}

body[data-page="print"] #printQuoteSummaryPage .summary-card {
  padding: 12px 14px;
}

body[data-page="print"] #printQuoteSummaryPage .summary-row {
  padding: 7px 0;
}

body[data-page="print"] .print-terms-section {
  margin-top: 10px;
}

body[data-page="print"] .print-terms-card {
  padding: 12px 14px;
  border-radius: 16px;
}

body[data-page="print"] .print-terms-head {
  margin-bottom: 8px;
}

body[data-page="print"] .print-terms-card ul {
  line-height: 1.38;
}

body[data-page="print"] .print-remark-box {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 14px;
}

body[data-page="print"] .print-remark-box p {
  line-height: 1.4;
}

@page {
  size: A4 portrait;
  margin: 5mm;
}

@media print {
  html,
  body {
    margin: 0;
    padding: 0;
  }

  body[data-page="print"] {
    background: #fff;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
  }

  body[data-page="print"] .print-sheet,
  body[data-page="print"] .print-total-hero,
  body[data-page="print"] .print-total-amount,
  body[data-page="print"] .print-terms-card,
  body[data-page="print"] .print-remark-box,
  body[data-page="print"] .print-info-card,
  body[data-page="print"] .print-info-grid div,
  body[data-page="print"] .summary-card,
  body[data-page="print"] table,
  body[data-page="print"] th {
    background: #fff !important;
    box-shadow: none !important;
  }

  * {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body[data-page="print"] .print-sheet:nth-of-type(2),
  body[data-page="print"] .print-sheet:nth-of-type(3) {
    break-before: page;
    page-break-before: always;
  }

  body[data-page="print"] .print-shell {
    padding: 0;
  }

  body[data-page="print"] .print-sheet:first-of-type {
    margin: 0;
    padding: 13px 14px;
    border-radius: 22px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-brand,
  body[data-page="print"] .print-sheet:first-of-type .print-document-hero {
    margin-bottom: 9px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-total-hero {
    gap: 10px;
    padding: 13px;
    border-radius: 18px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-total-copy h2 {
    margin: 0 0 4px;
    font-size: 29px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-total-amount {
    padding: 11px;
    border-radius: 15px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-total-amount strong {
    margin-top: 4px;
    font-size: 26px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-meta-grid {
    gap: 8px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-info-card {
    padding: 10px 11px;
    border-radius: 15px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-info-card h3 {
    margin-bottom: 7px;
    font-size: 16px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-info-grid {
    gap: 6px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-info-grid div {
    padding: 6px 7px;
    border-radius: 10px;
  }

  body[data-page="print"] .print-sheet:first-of-type #printQuoteSummaryPage .summary-card {
    padding: 9px 11px;
  }

  body[data-page="print"] .print-sheet:first-of-type #printQuoteSummaryPage .summary-row {
    padding: 4px 0;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-terms-section {
    margin-top: 7px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-terms-card {
    padding: 9px 11px;
    border-radius: 13px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-terms-head {
    margin-bottom: 5px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-terms-card ul {
    line-height: 1.24;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-remark-box {
    margin-top: 6px;
    padding: 7px 9px;
    border-radius: 11px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-remark-box span {
    margin-bottom: 3px;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-remark-box p {
    line-height: 1.24;
  }

  body[data-page="print"] thead {
    display: table-header-group;
  }

  body[data-page="print"] tr,
  body[data-page="print"] .detail-row,
  body[data-page="print"] .print-detail-table .print-process-heading-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

body[data-page="detail"] .detail-sheet-section input,
body[data-page="detail"] .detail-sheet-section textarea {
  caret-color: var(--accent-strong);
}

@media screen and (max-width: 860px) {
  .margin-accordion-trigger {
    min-height: 84px;
    padding: 16px;
  }

  .margin-accordion-trigger > span:first-child {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .margin-accordion-panel {
    padding: 2px 14px 16px;
  }

  .item-margin-toolbar {
    grid-template-columns: 1fr;
  }

  .process-margin-savebar,
  .item-margin-savebar {
    align-items: stretch;
    flex-direction: column;
  }

  .process-margin-savebar .margin-action-row,
  .item-margin-savebar .margin-action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .process-margin-savebar button,
  .item-margin-savebar button {
    width: 100%;
  }
}

/* Detail estimate: per-line delete action */
body[data-page="detail"] .detail-estimate-table .line-select-column {
  left: 26px;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  padding-inline: 4px;
}

body[data-page="detail"] .detail-estimate-table .line-item-column {
  left: 90px;
}

body[data-page="detail"] .detail-estimate-table th.line-select-column {
  font-size: 10px;
  line-height: 1.2;
  white-space: normal;
}

body[data-page="detail"] .line-row-actions,
body[data-page="detail"] .line-card-head-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

body[data-page="detail"] .line-delete-button {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(180, 35, 24, 0.24);
  border-radius: 8px;
  color: #b42318;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

body[data-page="detail"] .line-delete-button:hover,
body[data-page="detail"] .line-delete-button:focus-visible {
  border-color: rgba(180, 35, 24, 0.48);
  outline: none;
  color: #8f1c13;
  background: #fff1ef;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}

body[data-page="detail"] .line-delete-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

body[data-page="detail"] .line-card-head-actions {
  flex: 0 0 auto;
  align-items: flex-start;
}

body[data-page="detail"] .line-card-delete-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  border-radius: 10px;
}

@media screen and (max-width: 860px) {
  body[data-page="detail"] .line-card-delete-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
}

/* EASE MINI V2 · 견적 → 일정예약 → 계약 */
button.workflow-action,
.saved-actions button.workflow-action {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #8a642f, #c69a58);
  box-shadow: 0 12px 24px rgba(92, 63, 24, 0.16);
}

.document-workflow-panel {
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(360px, 1.28fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 20px;
  border: 1px solid rgba(138, 100, 47, 0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(247, 242, 230, 0.94));
  box-shadow: var(--shadow);
}

.document-workflow-panel[hidden] {
  display: none;
}

.document-workflow-copy {
  display: grid;
  gap: 4px;
}

.document-workflow-copy .eyebrow {
  margin: 0;
}

.document-workflow-copy > strong {
  font-size: 16px;
}

.document-workflow-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.document-workflow-numbers em {
  padding: 3px 7px;
  border: 1px solid rgba(138, 100, 47, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
}

.document-workflow-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-workflow-steps::before {
  position: absolute;
  top: 16px;
  right: 16%;
  left: 16%;
  height: 1px;
  background: var(--line-strong);
  content: "";
}

.document-workflow-steps li {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.document-workflow-steps li > span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--panel-strong);
  font-size: 12px;
  font-weight: 800;
}

.document-workflow-steps li > strong {
  font-size: 12px;
}

.document-workflow-steps li.is-active {
  color: var(--text);
}

.document-workflow-steps li.is-active > span {
  color: #fff;
  border-color: #8a642f;
  background: #8a642f;
  box-shadow: 0 0 0 4px rgba(138, 100, 47, 0.12);
}

.document-workflow-steps li.is-complete > span {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.document-workflow-steps li.is-disabled {
  opacity: 0.58;
}

.document-workflow-steps li.is-skipped {
  opacity: 0.72;
}

.document-workflow-steps li.is-skipped > span {
  border-style: dashed;
}

.admin-workflow-settings {
  grid-column: 1 / -1;
}

.workflow-settings-groups {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.workflow-settings-group {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.workflow-settings-group legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.payment-rate-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.workflow-settings-group .form-field-wide {
  grid-column: 1 / -1;
}

.workflow-settings-group input[readonly] {
  color: var(--muted);
  background: #f1f2ed;
}

@media screen and (max-width: 860px) {
  .document-workflow-panel {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .document-workflow-copy {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .document-workflow-copy .eyebrow,
  .document-workflow-numbers {
    grid-column: 1 / -1;
  }

  .document-workflow-steps li > strong {
    font-size: 11px;
  }

  .workflow-settings-groups,
  .payment-rate-settings {
    grid-template-columns: 1fr 1fr;
  }

  body[data-page="detail"] .mobile-total-actions button.workflow-action {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.24);
    background: #a77838;
  }
}

@media screen and (max-width: 560px) {
  .workflow-settings-groups,
  .payment-rate-settings {
    grid-template-columns: 1fr;
  }
}

/* Mobile workspace: keep every workflow usable at 360-430px without changing print output. */
@media (hover: none) and (pointer: coarse) {
  .nav-chip:hover,
  .button-link:hover,
  button:hover {
    transform: none;
    box-shadow: none;
  }
}

@media screen and (max-width: 860px) {
  body[data-page="detail"] {
    padding-bottom: calc(224px + env(safe-area-inset-bottom));
  }

  .shell,
  .print-shell {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .topbar {
    gap: 12px;
    margin-bottom: 12px;
    padding: 13px;
    border-radius: 14px;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.035);
    backdrop-filter: none;
  }

  .brand-lockup {
    gap: 11px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
    border-radius: 12px;
  }

  .brand-block {
    overflow-wrap: anywhere;
  }

  .brand-block .eyebrow {
    margin-bottom: 5px;
    font-size: 10px;
  }

  .brand-block h1 {
    font-size: clamp(21px, 6.2vw, 26px);
    line-height: 1.12;
  }

  .header-controls {
    width: 100%;
    gap: 10px;
  }

  .page-nav {
    display: flex;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1px 0 3px;
    scroll-padding-inline: 2px;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .page-nav::-webkit-scrollbar {
    display: none;
  }

  .page-nav .nav-chip {
    flex: 0 0 auto;
    min-height: 44px;
    padding-inline: 13px;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .topbar-actions > button,
  .topbar-actions > .button-link {
    min-width: 0;
    min-height: 44px;
    margin-top: 0;
  }

  .topbar-actions > #saveEstimateButton,
  .topbar-actions > .admin-session-tools {
    grid-column: 1 / -1;
  }

  .admin-session-tools {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
  }

  .admin-session-tools > .admin-session-badge {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-height: 44px;
    padding: 7px 10px;
    justify-content: center;
    overflow-wrap: anywhere;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
  }

  .admin-session-tools > .admin-account-link {
    grid-column: 1;
    grid-row: 1;
  }

  .admin-session-tools > .pending-approval-link {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .admin-session-tools > #authLogoutButton,
  .admin-session-tools > #auditLogoutButton {
    grid-column: 2;
    grid-row: 1;
  }

  .admin-session-tools .admin-logout-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0 7px;
    font-size: 12px;
    white-space: normal;
  }

  input,
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
  }

  textarea {
    min-height: 88px;
  }

  button,
  .button-link,
  .adjustment-toggle {
    min-height: 44px;
  }

  .panel,
  .hero-panel {
    margin-bottom: 11px;
    padding: 13px;
  }

  .panel-header {
    gap: 10px;
    margin-bottom: 10px;
  }

  .metrics,
  .hero-meta-grid,
  .saved-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    margin-top: 6px;
    font-size: clamp(18px, 5.4vw, 23px);
    overflow-wrap: anywhere;
  }

  .hero-meta-grid .hero-meta-wide,
  .hero-meta-grid .hero-meta-accent {
    grid-column: 1 / -1;
  }

  .hero-total-card strong {
    max-width: 100%;
    font-size: clamp(27px, 8.8vw, 34px);
    overflow-wrap: anywhere;
  }

  .detail-header-controls {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 8px;
    align-items: end;
  }

  .detail-header-controls .compact-label {
    min-width: 0;
  }

  .detail-header-controls .short-button {
    min-width: 0;
    margin-top: 0;
  }

  .line-card {
    padding: 14px;
    border-radius: 17px;
  }

  .line-card-grid,
  .line-card-totals,
  .cost-item-prices,
  .process-margin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .line-card-field:last-child:nth-child(odd),
  .line-card-totals .summary-chip:last-child {
    grid-column: 1 / -1;
  }

  .line-card [data-action] {
    scroll-margin-top: 92px;
    scroll-margin-bottom: 190px;
  }

  .summary-row > span,
  .build-up-copy {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .summary-row > strong,
  .build-up-row > strong {
    flex: 0 0 auto;
  }

  .saved-meta-grid div:nth-child(3),
  .saved-meta-grid div:last-child {
    grid-column: 1 / -1;
  }

  .saved-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .saved-actions button {
    min-width: 0;
    padding-inline: 6px;
  }

  .admin-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-shortcuts .button-link {
    min-width: 0;
  }

  .approval-request-card {
    flex-direction: column;
    align-items: stretch;
  }

  .approval-request-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .approval-request-actions .short-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }

  .approval-request-actions .short-button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .process-margin-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .process-margin-button {
    width: 100%;
    min-width: 0;
  }

  .cost-item-editor-panel {
    scroll-margin-top: 10px;
  }

  .table-wrap {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  body[data-page="detail"] .detail-sheet-section > .table-wrap {
    display: block;
  }

  body[data-page="detail"] .mobile-line-cards {
    display: none;
  }

  body[data-page="detail"] .detail-table-wrap {
    max-height: none;
    border-radius: 12px;
  }

  body[data-page="detail"] .detail-estimate-table {
    min-width: 1000px;
  }

  body[data-page="detail"] .detail-estimate-table th,
  body[data-page="detail"] .detail-estimate-table td {
    padding: 9px 8px;
  }

  body[data-page="detail"] .detail-estimate-table .line-item-column {
    min-width: 184px;
    max-width: 220px;
  }

  body[data-page="detail"] .detail-estimate-table input[type="number"],
  body[data-page="detail"] .detail-estimate-table .vendor-cost-input {
    min-width: 108px;
    min-height: 48px;
    padding: 10px;
    font-size: 16px;
  }

  body[data-page="detail"] .detail-estimate-table select {
    min-height: 48px;
    font-size: 16px;
  }

  body[data-page="detail"] .detail-estimate-table textarea {
    min-width: 220px;
    min-height: 76px;
    font-size: 16px;
  }

  body[data-page="detail"] .detail-estimate-table .line-drag-handle {
    min-width: 44px;
    min-height: 48px;
    margin: 0;
    padding-inline: 0;
  }

  body[data-page="detail"] .detail-estimate-table [data-action] {
    scroll-margin-block: 82px 224px;
  }

  .cost-db-table {
    min-width: 840px;
  }

  body[data-page="margin"] .table-wrap table {
    min-width: 760px;
  }

  .user-management-table {
    min-width: 1040px;
  }

  .registration-details summary {
    display: flex;
    min-height: 44px;
    align-items: center;
    padding: 9px 2px;
  }

  .domain-input-group strong {
    padding: 0 9px;
    font-size: 12px;
  }

  .mobile-total-bar {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 7px;
    padding: 9px;
    border-radius: 18px;
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  body[data-page="detail"] #estimateSaveStatus {
    position: fixed;
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(142px + env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    z-index: 21;
    width: auto;
    min-height: 40px;
    margin: 0;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.15);
  }

  .mobile-total-copy {
    min-width: 0;
    padding: 8px 9px;
    border-radius: 13px;
  }

  .mobile-total-copy strong {
    display: block;
    font-size: clamp(12px, 3.6vw, 14px);
    white-space: nowrap;
  }

  .mobile-total-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .mobile-total-actions button {
    min-width: 0;
    min-height: 44px;
    margin: 0;
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.11);
    color: #fff;
  }

  .mobile-total-actions button.accent {
    background: #fff;
    color: #1e342d;
  }

  body:has(input:focus, select:focus, textarea:focus) .mobile-total-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 36px));
  }

  body[data-page="detail"]:has(input:focus, select:focus, textarea:focus) #estimateSaveStatus {
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 36px));
  }
}

@media screen and (max-width: 1024px) {
  .project-quote-status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .project-quote-pending-count {
    align-self: flex-start;
  }

  .project-cost-table-row .project-cost-editor {
    position: sticky;
    left: 8px;
    width: min(760px, calc(100vw - 52px));
    max-width: none;
  }

  .project-cost-editor-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .project-cost-field input,
  .project-cost-field textarea,
  .project-cost-permission-toggle {
    min-height: 48px;
  }
}

@media screen and (max-width: 600px) {
  .project-cost-editor-grid {
    grid-template-columns: 1fr;
  }

  .project-cost-reason-field {
    grid-column: 1;
  }

  .vendor-quote-editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .saved-filter-grid {
    grid-template-columns: 1fr;
  }

  .saved-pagination button {
    min-width: 60px;
    padding-inline: 10px;
  }

  body:not([data-page="login"]) .brand-block > .muted {
    display: none;
  }

  .hero-terms-panel,
  .saved-card,
  .process-margin-card,
  .approval-request-panel {
    padding: 12px;
    border-radius: 15px;
  }

  .brand-preview {
    flex-direction: column;
    align-items: flex-start;
  }

  body[data-page="print"] .print-shell {
    padding: 0 8px 12px;
  }

  body[data-page="print"] .print-sheet {
    padding: 13px;
    border-radius: 16px;
  }

  body[data-page="print"] .print-total-hero,
  body[data-page="print"] .print-meta-grid,
  body[data-page="print"] .print-info-grid,
  body[data-page="print"] .print-company-card,
  body[data-page="print"] .print-company-grid {
    grid-template-columns: 1fr;
  }

  body[data-page="print"] .print-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body[data-page="print"] .print-detail-table {
    min-width: 720px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Estimate workflow: autosave, customer editor, clone and reuse */
.estimate-save-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(63, 115, 99, 0.18);
  border-radius: 999px;
  background: rgba(244, 248, 245, 0.94);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.estimate-save-status[data-tone="saving"] {
  color: #765116;
  background: #fff8e6;
  border-color: rgba(197, 142, 37, 0.25);
}

.estimate-save-status[data-tone="success"] {
  color: #16654d;
  background: #edf8f2;
  border-color: rgba(22, 101, 77, 0.22);
}

.estimate-save-status[data-tone="error"],
.estimate-save-status[data-tone="conflict"] {
  color: #a43125;
  background: #fff2f0;
  border-color: rgba(180, 35, 24, 0.24);
}

.estimate-save-retry {
  width: auto;
  min-width: 0;
  min-height: 28px;
  margin: 0;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.estimate-save-retry:hover,
.estimate-save-retry:focus-visible {
  background: transparent;
  color: #7f1d1d;
}

.estimate-access-notice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid rgba(34, 92, 135, 0.22);
  border-radius: 999px;
  background: #f2f8fc;
  color: #225c87;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

body.is-shared-estimate-readonly #summaryRemark,
body.is-shared-estimate-readonly [data-action]:disabled {
  cursor: not-allowed;
  background: #f5f6f4;
  color: var(--muted);
}

.customer-info-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.customer-info-summary > div,
.assigned-staff-readonly {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid rgba(26, 33, 42, 0.08);
  border-radius: 12px;
  background: rgba(248, 250, 246, 0.92);
}

.customer-info-summary span,
.assigned-staff-readonly span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.customer-info-summary strong,
.assigned-staff-readonly strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.customer-info-summary .customer-info-wide {
  grid-column: 1 / -1;
}

.app-dialog {
  width: min(680px, calc(100vw - 28px));
  max-width: 680px;
  max-height: min(860px, calc(100dvh - 28px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  background: transparent;
  box-shadow: 0 28px 80px rgba(21, 33, 29, 0.28);
}

.app-dialog::backdrop {
  background: rgba(17, 26, 23, 0.56);
  backdrop-filter: blur(4px);
}

.dialog-card {
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: inherit;
  background: #fff;
}

.dialog-card-compact {
  max-width: 560px;
}

.estimate-settings-dialog {
  width: min(900px, calc(100vw - 32px));
}

.estimate-settings-dialog-card {
  width: 100%;
  max-width: 900px;
}

.estimate-settings-section {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 250, 246, 0.62);
}

.estimate-settings-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.estimate-settings-section-header h3 {
  margin: 0;
  font-size: 18px;
}

.estimate-settings-section-header .eyebrow {
  margin-bottom: 4px;
}

.estimate-settings-adjustments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 13px;
}

.estimate-settings-adjustments label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
}

.estimate-settings-adjustments input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.estimate-settings-term-list {
  max-height: 310px;
  overflow-y: auto;
  padding-right: 3px;
}

.estimate-settings-empty-terms {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
}

.estimate-settings-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.estimate-settings-dialog-actions > button,
.estimate-settings-dialog-actions .dialog-actions {
  margin-top: 0;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.dialog-header .eyebrow {
  margin-bottom: 5px;
}

.dialog-close {
  flex: 0 0 42px;
  width: 42px;
  min-height: 42px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 25px;
  line-height: 1;
}

.dialog-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.dialog-form-grid label {
  margin-top: 0;
}

.dialog-form-grid [hidden] {
  display: none !important;
}

.dialog-field-wide {
  grid-column: 1 / -1;
}

.dialog-feedback {
  min-height: 20px;
  margin-top: 12px;
  color: #a43125;
  font-size: 12px;
}

.dialog-feedback[data-tone="success"] {
  color: #16654d;
}

.dialog-feedback[data-tone="warning"] {
  color: #765116;
}

.dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 8px;
}

.dialog-actions button {
  margin-top: 0;
}

.dialog-description {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.estimate-refresh-dialog .dialog-card {
  max-width: 500px;
}

.estimate-refresh-options {
  display: grid;
  gap: 10px;
}

.estimate-refresh-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: flex-start;
  gap: 12px;
  margin: 0;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8faf9;
  cursor: pointer;
}

.estimate-refresh-option:has(input:checked) {
  border-color: rgba(63, 115, 99, 0.45);
  background: rgba(63, 115, 99, 0.08);
}

.estimate-refresh-option input {
  width: 19px;
  height: 19px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.estimate-refresh-option strong,
.estimate-refresh-option small {
  display: block;
}

.estimate-refresh-option strong {
  margin-bottom: 5px;
  color: var(--text);
  font-size: 14px;
}

.estimate-refresh-option small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
}

.new-estimate-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-card {
  min-height: 132px;
  margin: 0;
  padding: 18px;
  text-align: left;
}

.choice-card strong,
.choice-card span {
  display: block;
}

.choice-card strong {
  margin-bottom: 9px;
  color: var(--text);
  font-size: 15px;
}

.choice-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
}

.saved-actions [data-saved-action="copy"],
.saved-actions [data-action="copy"] {
  color: #225c87;
  border-color: rgba(34, 92, 135, 0.22);
  background: #f2f8fc;
}

.saved-actions [data-saved-action="reuse"],
.saved-actions [data-action="reuse"] {
  color: #765116;
  border-color: rgba(197, 142, 37, 0.24);
  background: #fff9ea;
}

@media screen and (max-width: 860px) {
  .estimate-save-status,
  .estimate-access-notice {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 38px;
  }

  .customer-info-summary,
  .dialog-form-grid,
  .new-estimate-options {
    grid-template-columns: 1fr;
  }

  .estimate-settings-adjustments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .estimate-settings-dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .estimate-settings-dialog-actions > button {
    width: 100%;
  }

  .customer-info-summary .customer-info-wide,
  .dialog-field-wide {
    grid-column: auto;
  }

  .app-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100dvh - 18px);
    border-radius: 17px;
  }

  .dialog-card {
    padding: 17px;
  }

  .choice-card {
    min-height: 104px;
  }

  .saved-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.login-preference-row {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  flex-wrap: wrap;
}

.remember-id-control {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  margin: 0;
  cursor: pointer;
  font-weight: 700;
}

.remember-id-control input[type="checkbox"] {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent-strong);
}

.remember-id-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.owner-danger-zone,
.operation-safety-block {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(180, 35, 24, 0.18);
  border-radius: 14px;
  background: rgba(255, 249, 247, 0.72);
}

.owner-danger-zone[hidden],
.operation-safety-block[hidden],
[data-owner-only][hidden] {
  display: none !important;
}

.owner-danger-zone button,
.operation-safety-block button {
  margin-top: 0;
}

.operation-feedback {
  min-height: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.55;
}

.operation-feedback[data-tone="pending"] {
  color: #765116;
}

.operation-feedback[data-tone="warning"] {
  color: #9a5b12;
}

.operation-feedback[data-tone="success"] {
  color: #16654d;
}

.operation-feedback[data-tone="error"] {
  color: #b42318;
}

.operation-feedback[data-tone="info"] {
  color: #245f78;
}

.it-review-banner {
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px 18px;
  min-height: 48px;
  padding: 10px 20px;
  color: #fff7ed;
  background: #7c2d12;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 24px rgba(69, 26, 3, 0.2);
  text-align: center;
}

.it-review-banner strong {
  font-size: 14px;
  letter-spacing: 0.03em;
}

.it-review-banner span {
  font-size: 12px;
  font-weight: 650;
}

.is-it-review-mode button:disabled,
.is-it-review-mode input:disabled,
.is-it-review-mode select:disabled,
.is-it-review-mode textarea:disabled {
  cursor: not-allowed;
}

.review-link-panel {
  grid-column: 1 / -1;
}

.review-link-safety-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid rgba(154, 91, 18, 0.2);
  border-radius: 12px;
  color: #765116;
  background: rgba(255, 248, 227, 0.7);
  font-size: 12px;
  line-height: 1.55;
}

.review-link-once {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(63, 115, 99, 0.24);
  border-radius: 14px;
  background: rgba(232, 242, 236, 0.68);
}

.review-link-once[hidden] {
  display: none !important;
}

.review-link-once label,
.review-link-once input {
  min-width: 0;
}

.review-link-list {
  display: grid;
  gap: 9px;
}

.review-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.review-link-item-copy,
.review-link-item-copy > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.review-link-item-copy {
  align-items: flex-start;
  flex-direction: column;
}

.review-link-item-copy p {
  margin: 0;
  font-size: 12px;
}

.review-link-status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  color: #16654d;
  background: rgba(22, 101, 77, 0.1);
  font-size: 11px;
  font-weight: 750;
}

.review-link-status.is-used,
.review-link-status.is-expired,
.review-link-status.is-revoked {
  color: var(--muted);
  background: rgba(102, 116, 109, 0.1);
}

.review-access-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 22px;
}

.review-access-card {
  width: min(100%, 560px);
  padding: clamp(24px, 5vw, 42px);
}

.review-access-card h1 {
  margin: 4px 0 12px;
  font-size: clamp(28px, 6vw, 42px);
}

.review-access-lead,
.review-access-note {
  line-height: 1.65;
}

.review-access-rules {
  display: grid;
  gap: 10px;
  margin: 22px 0;
  padding: 18px 18px 18px 36px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.65);
  line-height: 1.55;
}

.review-access-start {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
}

.review-access-note {
  margin: 14px 0 0;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 640px) {
  .it-review-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 2px;
  }

  .review-link-once {
    grid-template-columns: 1fr;
  }

  .review-link-item {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  .it-review-banner {
    display: none !important;
  }
}

/* EASE MINI estimate document - output-only layout */
@font-face {
  font-family: "Ease Print";
  src: url("/app/assets/fonts/NanumGothic-Regular.ttf?v=20260731vectorpdf1") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Ease Print";
  src: url("/app/assets/fonts/NanumGothic-Bold.ttf?v=20260731vectorpdf1") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Ease Legal Marker";
  src: url("/app/assets/fonts/NotoSansKR-LegalMarkers.ttf?v=20260916symbols1") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

body[data-page="print"] {
  --print-page-width: 210mm;
  --print-page-height: 297mm;
  --print-margin-x: 12mm;
  --print-margin-top: 10mm;
  --print-margin-bottom: 8mm;
  --print-footer-height: 7mm;
  background: #eef2ef;
  color: var(--text);
  font-family: "Ease Print", "Nanum Gothic", sans-serif;
}

body[data-page="print"] .print-shell,
body[data-page="print"] .print-measure-host {
  width: var(--print-page-width);
  max-width: var(--print-page-width);
}

body[data-page="print"] .print-preview-stage {
  width: var(--print-page-width);
  margin: 0 auto;
}

body[data-page="print"] .print-preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  width: min(var(--print-page-width), calc(100% - 24px));
  min-height: 58px;
  margin: 12px auto 0;
  padding: 10px 12px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
}

body[data-page="print"] .print-preview-toolbar-copy {
  display: grid;
  gap: 2px;
}

body[data-page="print"] .print-preview-toolbar-copy strong {
  font-size: 14px;
}

body[data-page="print"] .print-preview-toolbar-copy span {
  color: var(--muted);
  font-size: 12px;
}

body[data-page="print"] .print-preview-toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

body[data-page="print"] .print-preview-toolbar button {
  width: auto;
  min-height: 38px;
  margin: 0;
  padding-inline: 14px;
}

body[data-page="print"] .print-shell {
  margin: 0 auto;
  padding: 12px 0 24px;
}

body[data-page="print"] .print-measure-host {
  position: fixed;
  top: 0;
  left: -300vw;
  z-index: -1;
  pointer-events: none;
  visibility: hidden;
}

body[data-page="print"] .print-measure-host .print-sheet {
  height: 288mm;
}

body[data-page="print"] .print-sheet {
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--print-footer-height);
  width: var(--print-page-width);
  height: var(--print-page-height);
  margin: 0 auto 12px;
  padding: var(--print-margin-top) var(--print-margin-x) var(--print-margin-bottom);
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

body[data-page="print"] .print-page-body {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

body[data-page="print"] .print-document-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58mm;
  grid-template-rows: auto auto;
  gap: 2mm 4mm;
  align-items: end;
  padding-bottom: 3.5mm;
  border-bottom: 0.35mm solid var(--line-strong);
}

body[data-page="print"] .print-title-lockup {
  display: grid;
  grid-column: 1;
  grid-row: 2;
  grid-template-columns: max-content max-content;
  gap: 0 2.5mm;
  align-items: center;
  justify-content: start;
}

body[data-page="print"] .print-title-lockup .print-brand-mark {
  width: 10mm;
  height: 10mm;
  border-radius: 1.5mm;
}

body[data-page="print"] .print-title-lockup .brand-logo-image {
  padding: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: left center;
}

body[data-page="print"] .print-title-lockup .print-brand-mark.has-logo {
  width: 75.6mm;
  height: 22.68mm;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body[data-page="print"] .print-title-lockup .print-brand-mark.has-logo + .print-brand-word {
  display: none;
}

body[data-page="print"] .print-brand-word {
  font-size: 11pt;
  font-weight: 800;
  letter-spacing: 0.02em;
}

body[data-page="print"] .print-title-lockup h1 {
  grid-column: 1 / -1;
  margin: 2.7mm 0 0;
  font-size: 25pt;
  line-height: 1;
  letter-spacing: -0.06em;
}

body[data-page="print"] .print-document-meta {
  display: grid;
  grid-column: 2;
  grid-row: 2;
  gap: 1.5mm;
  margin: 0;
}

body[data-page="print"] .print-document-meta > div {
  display: grid;
  grid-template-columns: 17mm minmax(0, 1fr);
  gap: 2mm;
  align-items: baseline;
}

body[data-page="print"] .print-document-meta dt,
body[data-page="print"] .print-document-meta dd {
  margin: 0;
  font-size: 7.8pt;
  line-height: 1.35;
}

body[data-page="print"] .print-document-meta dt {
  color: var(--muted);
}

body[data-page="print"] .print-document-meta dd {
  overflow-wrap: anywhere;
  font-weight: 650;
}

body[data-page="print"] .print-info-section {
  margin-top: 3.4mm;
}

body[data-page="print"] .print-info-section h2,
body[data-page="print"] .print-section-title h2,
body[data-page="print"] .print-detail-page-header h2 {
  margin: 0;
  font-size: 11pt;
  line-height: 1.25;
  letter-spacing: -0.035em;
}

body[data-page="print"] .print-info-section h2 {
  margin-bottom: 1.7mm;
}

body[data-page="print"] .print-info-grid {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-top: 0.25mm solid var(--line);
  border-left: 0.25mm solid var(--line);
}

body[data-page="print"] .print-info-grid > .print-info-cell {
  flex: 1 1 0;
  min-width: 0;
  padding: 1.7mm 2mm;
  border: 0;
  border-right: 0.25mm solid var(--line);
  border-bottom: 0.25mm solid var(--line);
  border-radius: 0 !important;
  background: #fff;
  box-shadow: none;
}

body[data-page="print"] .print-info-grid > .print-info-cell.is-address {
  flex-grow: 3;
}

body[data-page="print"] .print-info-grid > .print-info-cell span {
  display: block;
  margin-bottom: 0.7mm;
  color: var(--muted);
  font-size: 6.6pt;
  line-height: 1.25;
}

body[data-page="print"] .print-info-grid > .print-info-cell strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 7.8pt;
  font-weight: 650;
  line-height: 1.35;
}

body[data-page="print"] .print-info-grid > .print-info-cell.is-address strong {
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

body[data-page="print"] .print-total-hero {
  display: grid;
  grid-template-columns: 64mm minmax(0, 1fr);
  gap: 0;
  min-height: 44mm;
  margin-top: 4mm;
  padding: 0;
  overflow: hidden;
  border: 0.35mm solid var(--accent);
  border-radius: 1.5mm;
  background: #fff;
}

body[data-page="print"] .print-total-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  padding: 4mm 5mm;
  border-right: 0.25mm solid var(--line);
  background: var(--accent-soft);
}

body[data-page="print"] .print-total-label,
body[data-page="print"] .print-vat-label {
  grid-column: 1 / -1;
}

body[data-page="print"] .print-total-label {
  color: var(--accent);
  font-size: 8.4pt;
  font-weight: 750;
}

body[data-page="print"] .print-vat-label {
  margin-top: 0.8mm;
  color: var(--muted);
  font-size: 6.8pt;
}

body[data-page="print"] .print-total-value {
  align-self: end;
  margin-top: 3mm;
  color: var(--text);
  font-size: 25pt;
  line-height: 1;
  letter-spacing: -0.045em;
  white-space: nowrap;
}

body[data-page="print"] .print-money-unit {
  align-self: end;
  padding: 0 0 0.4mm 1.8mm;
  color: var(--muted);
  font-size: 7pt;
}

body[data-page="print"] .print-total-breakdown {
  display: grid;
  align-content: center;
  padding: 2.5mm 4mm;
}

body[data-page="print"] .print-breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4mm;
  align-items: baseline;
  padding: 1.15mm 0;
  border-bottom: 0.2mm solid var(--line);
  font-size: 9.3pt;
  line-height: 1.2;
}

body[data-page="print"] .print-breakdown-row:last-child {
  border-bottom: 0;
}

body[data-page="print"] .print-breakdown-row span {
  color: var(--muted);
}

body[data-page="print"] .print-breakdown-row strong {
  color: var(--text);
  font-weight: 650;
  white-space: nowrap;
}

body[data-page="print"] .print-breakdown-row.is-subtotal span,
body[data-page="print"] .print-breakdown-row.is-subtotal strong,
body[data-page="print"] .print-breakdown-row.is-grand span,
body[data-page="print"] .print-breakdown-row.is-grand strong {
  color: var(--text);
  font-weight: 800;
}

body[data-page="print"] .print-breakdown-row.is-grand {
  border-top: 0.35mm solid var(--accent);
}

body[data-page="print"] .print-breakdown-row.is-grand span,
body[data-page="print"] .print-breakdown-row.is-grand strong {
  color: var(--accent);
}

body[data-page="print"] .print-breakdown-row.is-adjustment strong {
  color: var(--muted);
}

body[data-page="print"] .print-process-summary,
body[data-page="print"] .print-notes {
  margin-top: 4mm;
}

body[data-page="print"] .print-section-title,
body[data-page="print"] .print-detail-page-header {
  display: flex;
  justify-content: space-between;
  gap: 5mm;
  align-items: baseline;
  margin-bottom: 1.8mm;
}

body[data-page="print"] .print-section-title > span,
body[data-page="print"] .print-detail-page-header > span {
  color: var(--muted);
  font-size: 6.8pt;
}

body[data-page="print"] .print-process-summary .print-section-title h2,
body[data-page="print"] .print-notes .print-section-title h2 {
  font-size: 12pt;
}

body[data-page="print"] .print-process-summary .print-section-title > span {
  font-size: 7.3pt;
}

body[data-page="print"] .print-process-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7mm;
}

body[data-page="print"] .print-process-column table,
body[data-page="print"] .print-detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

body[data-page="print"] .print-process-column th,
body[data-page="print"] .print-process-column td {
  height: 4.8mm;
  padding: 0.9mm 1.6mm;
  border-bottom: 0.2mm solid var(--line);
  font-size: 7.9pt;
  line-height: 1.25;
}

body[data-page="print"] .print-process-column th {
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 7.3pt;
  font-weight: 750;
  text-align: left;
}

body[data-page="print"] .print-process-column th:first-child,
body[data-page="print"] .print-process-column td:first-child {
  width: 12mm;
}

body[data-page="print"] .print-process-column th:last-child,
body[data-page="print"] .print-process-column td:last-child {
  width: 28mm;
  text-align: right;
}

body[data-page="print"] .print-process-number {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

body[data-page="print"] .print-notes {
  border-top: 0.25mm solid var(--line-strong);
  padding-top: 2.5mm;
}

body[data-page="print"] .print-note-content {
  padding: 2.2mm 3mm;
  border: 0.25mm solid var(--line);
}

body[data-page="print"] .print-note-line {
  position: relative;
  margin: 0 0 1.1mm;
  padding-left: 3.2mm;
  color: var(--text);
  font-size: 8pt;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

body[data-page="print"] .print-note-line:last-child {
  margin-bottom: 0;
}

body[data-page="print"] .print-note-line.is-term::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

body[data-page="print"] .print-note-line.is-remark {
  color: var(--muted);
}

body[data-page="print"] .print-detail-page-header {
  margin-bottom: 3mm;
  padding-bottom: 2.2mm;
  border-bottom: 0.35mm solid var(--accent);
}

body[data-page="print"] .print-detail-page-header h2 {
  font-size: 15pt;
}

body[data-page="print"] .print-detail-group {
  margin: 0 0 4mm;
  break-inside: avoid;
}

body[data-page="print"] .print-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 5mm;
  align-items: center;
  min-height: 9mm;
  margin: 0;
  padding: 1.5mm 2mm;
  border-top: 0.25mm solid var(--line-strong);
  background: #fff;
}

body[data-page="print"] .print-detail-title {
  display: flex;
  gap: 2mm;
  align-items: center;
  min-width: 0;
}

body[data-page="print"] .print-detail-number {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-width: 8mm;
  height: 5.5mm;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 6.8pt;
  font-weight: 800;
}

body[data-page="print"] .print-detail-head h3 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 10pt;
  line-height: 1.3;
}

body[data-page="print"] .print-detail-head h3 small {
  color: var(--muted);
  font-size: 7pt;
  font-weight: 600;
}

body[data-page="print"] .print-detail-total {
  display: flex;
  flex: 0 0 auto;
  gap: 2.2mm;
  align-items: baseline;
  font-size: 6.2pt;
}

body[data-page="print"] .print-detail-total span {
  display: inline-flex;
  gap: 0.8mm;
  align-items: baseline;
  color: var(--muted);
  white-space: nowrap;
}

body[data-page="print"] .print-detail-total strong {
  color: var(--text);
  font-size: 7.1pt;
  white-space: nowrap;
}

body[data-page="print"] .print-detail-table th,
body[data-page="print"] .print-detail-table td {
  min-width: 0;
  padding: 1.45mm 1.5mm;
  border-right: 0.2mm solid var(--line);
  border-bottom: 0.2mm solid var(--line);
  color: var(--text);
  font-size: 7.1pt;
  line-height: 1.35;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

body[data-page="print"] .print-detail-table th:first-child,
body[data-page="print"] .print-detail-table td:first-child {
  border-left: 0.2mm solid var(--line);
}

body[data-page="print"] .print-detail-table th {
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 6.5pt;
  font-weight: 750;
}

body[data-page="print"] .print-detail-table tr.is-print-continuation td {
  border-top: 0;
  color: var(--muted);
}

body[data-page="print"] .print-detail-table tr.is-print-continuation .print-money-cell {
  color: transparent;
}

body[data-page="print"] .print-detail-table {
  display: block;
}

body[data-page="print"] .print-detail-table-row {
  display: grid;
  width: 100%;
  grid-template-columns:
    minmax(0, 14fr) minmax(0, 13fr) minmax(0, 4fr) minmax(0, 5fr)
    repeat(6, minmax(0, 8fr)) minmax(0, 16fr);
}

body[data-page="print"] .print-detail-cell {
  min-width: 0;
  padding: 1mm 0.65mm;
  border-right: 0.2mm solid var(--line);
  border-bottom: 0.2mm solid var(--line);
  color: var(--text);
  font-size: 5.8pt;
  line-height: 1.3;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

body[data-page="print"] .print-process-memo-cell {
  grid-column: 1 / -1;
  font-size: 6.8pt;
  white-space: pre-wrap;
}

body[data-page="print"] .print-detail-table-row > .print-detail-cell:first-child {
  border-left: 0.2mm solid var(--line);
}

body[data-page="print"] .print-detail-table-head .print-detail-cell {
  display: grid;
  align-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 5.3pt;
  font-weight: 750;
  line-height: 1.18;
  vertical-align: middle;
}

body[data-page="print"] .print-detail-table-head {
  grid-template-rows: repeat(2, minmax(4.5mm, auto));
}

body[data-page="print"] .print-detail-table-head .print-header-rowspan {
  grid-row: 1 / span 2;
}

body[data-page="print"] .print-detail-table-head .print-item-cell { grid-column: 1; }
body[data-page="print"] .print-detail-table-head .print-spec-cell { grid-column: 2; }
body[data-page="print"] .print-detail-table-head .print-quantity-cell { grid-column: 3; }
body[data-page="print"] .print-detail-table-head .print-unit-cell { grid-column: 4; }

body[data-page="print"] .print-detail-table-head .print-money-group {
  grid-row: 1;
  border-bottom: 0.2mm solid var(--line);
  justify-items: center;
  text-align: center !important;
}

body[data-page="print"] .print-detail-table-head .print-material-group {
  grid-column: 5 / span 2;
}

body[data-page="print"] .print-detail-table-head .print-labor-group {
  grid-column: 7 / span 2;
}

body[data-page="print"] .print-detail-table-head .print-combined-header {
  grid-column: 9;
}

body[data-page="print"] .print-detail-table-head .print-total-header {
  grid-column: 10;
}

body[data-page="print"] .print-detail-table-head .print-combined-header,
body[data-page="print"] .print-detail-table-head .print-total-header {
  justify-items: center;
  text-align: center !important;
}

body[data-page="print"] .print-detail-table-head .print-remark-cell {
  grid-column: 11;
}

body[data-page="print"] .print-detail-table-head .print-money-subheader {
  grid-row: 2;
  justify-items: center;
  color: var(--muted);
  font-size: 4.8pt;
  font-weight: 650;
  text-align: center !important;
}

body[data-page="print"] .print-detail-table-head .print-material-unit-header { grid-column: 5; }
body[data-page="print"] .print-detail-table-head .print-material-amount-header { grid-column: 6; }
body[data-page="print"] .print-detail-table-head .print-labor-unit-header { grid-column: 7; }
body[data-page="print"] .print-detail-table-head .print-labor-amount-header { grid-column: 8; }

body[data-page="print"] .print-detail-table-row.is-print-continuation .print-detail-cell {
  border-top: 0;
  color: var(--muted);
}

body[data-page="print"] .print-detail-table-row.is-print-continuation .print-money-cell {
  color: transparent;
}

body[data-page="print"] .print-unit-cell,
body[data-page="print"] .print-quantity-cell {
  text-align: center !important;
}

body[data-page="print"] .print-money-cell {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap !important;
}

body[data-page="print"] .print-item-cell,
body[data-page="print"] .print-spec-cell,
body[data-page="print"] .print-remark-cell {
  overflow-wrap: anywhere;
  word-break: break-word;
}

body[data-page="print"] .print-footer {
  display: flex;
  justify-content: space-between;
  gap: 5mm;
  align-items: end;
  padding-top: 2mm;
  border-top: 0.2mm solid var(--line);
  color: var(--muted);
  font-size: 6.2pt;
}

body[data-page="print"] .print-footer-brand {
  display: flex;
  gap: 5mm;
  align-items: baseline;
}

body[data-page="print"] .print-footer-brand strong {
  color: var(--accent);
  font-size: 6.5pt;
}

body[data-page="print"] .print-page-number {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

body[data-page="print"][data-print-density="dense"] .print-info-section {
  margin-top: 2.5mm;
}

body[data-page="print"][data-print-density="dense"] .print-total-hero,
body[data-page="print"][data-print-density="dense"] .print-process-summary,
body[data-page="print"][data-print-density="dense"] .print-notes {
  margin-top: 3mm;
}

body[data-page="print"][data-print-density="dense"] .print-process-column th,
body[data-page="print"][data-print-density="dense"] .print-process-column td {
  height: 4.2mm;
  padding-block: 0.6mm;
  font-size: 7.4pt;
}

@media screen and (max-width: 860px) {
  body[data-page="print"] {
    width: 100%;
    min-width: 0;
    padding-bottom: calc(126px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  body[data-page="print"] .print-preview-toolbar {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 10px max(12px, env(safe-area-inset-right))
      calc(10px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 24px rgba(27, 46, 40, 0.12);
  }

  body[data-page="print"] .print-preview-toolbar-copy {
    gap: 1px;
  }

  body[data-page="print"] .print-preview-toolbar-copy span {
    line-height: 1.4;
  }

  body[data-page="print"] .print-preview-toolbar-actions {
    width: 100%;
  }

  body[data-page="print"] .print-preview-toolbar button {
    flex: 1 1 0;
    width: 100%;
    min-height: 46px;
    padding-inline: 12px;
  }

  body[data-page="print"] .print-preview-stage {
    width: 100%;
    min-height: 1px;
    margin: 0;
    padding: 8px 8px 0;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
  }

  body[data-page="print"] .print-shell {
    width: var(--print-page-width);
    max-width: none;
    margin: 0;
    transform: scale(var(--print-preview-scale, 1));
    transform-origin: top left;
  }

  body[data-page="print"] .print-sheet {
    box-shadow: 0 5px 18px rgba(27, 46, 40, 0.12);
  }

  body[data-page="print"] .print-detail-table {
    min-width: 0;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body[data-page="print"] {
    width: 210mm;
    min-width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body[data-page="print"] .print-shell {
    width: 210mm;
    max-width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  body[data-page="print"] .print-preview-stage {
    width: 210mm !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  body[data-page="print"] .print-preview-toolbar {
    display: none !important;
  }

  body[data-page="print"] .print-measure-host {
    display: none !important;
  }

  body[data-page="print"] .print-sheet,
  body[data-page="print"] .print-sheet:first-of-type {
    width: 210mm;
    height: 296mm;
    margin: 0 !important;
    padding: var(--print-margin-top) var(--print-margin-x) var(--print-margin-bottom) !important;
    overflow: clip !important;
    contain: layout paint;
    clip-path: inset(0);
    isolation: isolate;
    break-before: auto !important;
    page-break-before: auto !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    break-after: page !important;
    page-break-after: always !important;
    background: #fff !important;
  }

  body[data-page="print"] .print-page-body {
    overflow: clip !important;
    contain: layout paint;
  }

  body[data-page="print"] .print-sheet + .print-sheet {
    break-before: page !important;
    page-break-before: always !important;
  }

  body[data-page="print"] .print-sheet:last-child {
    break-after: auto !important;
    page-break-after: auto !important;
  }

  body[data-page="print"] .print-total-copy,
  body[data-page="print"] .print-process-column th,
  body[data-page="print"] .print-detail-number,
  body[data-page="print"] .print-detail-table-head .print-detail-cell {
    background: var(--accent-soft) !important;
  }

  body[data-page="print"] .print-sheet:first-of-type .print-total-hero {
    grid-template-columns: 64mm minmax(0, 1fr) !important;
    gap: 0 !important;
    min-height: 44mm;
    padding: 0 !important;
    border-radius: 1.5mm !important;
  }

  body[data-page="print"] .print-detail-page-header {
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  body[data-page="print"] .print-detail-group {
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  body[data-page="print"] .print-detail-table-row,
  body[data-page="print"] .print-detail-head {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

.operation-preview {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
}

.operation-preview-title {
  font-size: 14px;
}

.operation-preview-table {
  margin-top: 3px;
  overflow-x: auto;
  box-shadow: none;
}

.operation-preview-table table {
  min-width: 460px;
}

.operation-preview-table th,
.operation-preview-table td {
  padding: 9px 10px;
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.operation-preview-table th:first-child,
.operation-preview-table td:first-child {
  text-align: left;
}

/* Detail estimate productivity layout */
.topbar-actions > button,
.topbar-actions > .button-link {
  width: auto;
  min-height: 40px;
  margin-top: 0;
  padding-inline: 13px;
}

body[data-page="detail"] .detail-layout {
  display: block;
}

body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-row {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 66px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.72);
}

body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-row:last-child {
  border-bottom: 1px solid var(--line);
}

body[data-page="detail"] .topbar {
  align-items: center;
  padding: 12px 14px;
}

body[data-page="detail"] .brand-mark {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
}

body[data-page="detail"] .brand-block h1 {
  font-size: 27px;
}

body[data-page="detail"] .brand-block .muted {
  margin-top: 4px;
  font-size: 12px;
}

body[data-page="detail"] .header-controls {
  gap: 7px;
}

body[data-page="detail"] .page-nav,
body[data-page="detail"] .topbar-actions {
  gap: 6px;
}

body[data-page="detail"] .nav-chip {
  min-height: 38px;
  padding-inline: 12px;
}

.detail-header-actions {
  display: grid;
  gap: 7px;
  justify-items: end;
}

body[data-page="detail"] {
  overflow-x: clip;
}

.detail-selection-sticky {
  position: sticky;
  top: calc(var(--it-review-banner-height, 0px) + max(8px, env(safe-area-inset-top)));
  z-index: 30;
  display: flex;
  width: 100%;
  justify-content: flex-end;
  margin-bottom: 8px;
  pointer-events: none;
}

.line-selection-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid rgba(63, 115, 99, 0.18);
  border-radius: 10px;
  background: rgba(239, 247, 242, 0.96);
  box-shadow: 0 8px 24px rgba(31, 49, 43, 0.1);
  backdrop-filter: blur(12px);
  pointer-events: auto;
}

.line-selection-toolbar strong {
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}

.line-selection-toolbar span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.line-select-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.line-select-all span {
  color: var(--text);
  font-weight: 700;
}

.line-reorder-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.project-quote-status-row {
  justify-content: flex-end;
}

.detail-estimate-table {
  width: 100%;
  min-width: 1180px;
  table-layout: fixed;
}

.detail-estimate-table thead th {
  vertical-align: middle;
  text-align: center;
}

.detail-estimate-table .process-column-header th {
  position: static;
  z-index: auto;
  padding-block: 8px;
  border-top: 1px solid #dfe6e1;
  border-bottom: 1px solid #dfe6e1;
  background: #f7faf8;
  color: #44554f;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
  text-align: center;
  box-shadow: none;
}

.detail-estimate-table .process-column-header .line-money-column {
  text-align: right;
}

.detail-estimate-table .process-column-group-header .line-money-group {
  border-bottom: 0;
  background: #f7faf8;
  color: #44554f;
  text-align: center;
}

.detail-estimate-table .process-column-subheader th {
  padding-block: 5px 7px;
  border-top: 0;
  background: #f7faf8;
  font-size: 10px;
  text-align: center;
}

.detail-estimate-table .process-column-subheader .line-money-column {
  text-align: center;
}

.detail-estimate-table .process-column-header .line-item-column,
.detail-estimate-table .process-column-header .line-select-column {
  z-index: 1;
  background: #f7faf8;
}

.detail-estimate-table .line-select-column {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  padding-inline: 10px;
  text-align: center;
  background: #fff;
  box-shadow: 1px 0 0 #dfe6e1;
}

.detail-estimate-table thead .line-select-column {
  z-index: 7;
  background: #f7faf8;
}

.detail-estimate-table .line-item-column {
  position: sticky;
  left: 42px;
  z-index: 2;
  width: 175px;
  min-width: 175px;
  max-width: 190px;
  background: #fff;
  box-shadow: 1px 0 0 #dfe6e1, 8px 0 14px rgba(15, 23, 42, 0.035);
}

.detail-estimate-table thead .line-item-column {
  z-index: 6;
  background: #f7faf8;
}

.detail-estimate-table .line-category-column {
  width: 130px;
  min-width: 130px;
  max-width: 130px;
}

.detail-estimate-table .line-spec-column {
  width: 145px;
  min-width: 145px;
  max-width: 145px;
}

.detail-estimate-table .line-category-column select,
.detail-estimate-table .line-item-column select,
.detail-estimate-table .line-spec-column select {
  width: 100%;
  min-width: 0;
}

.detail-estimate-table th,
.detail-estimate-table td {
  padding-inline: 6px;
}

.detail-estimate-table .line-select-column input,
#selectAllLines,
.line-card-select input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.detail-estimate-table .line-quantity-column {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}

.detail-estimate-table .line-quantity-column [data-action="qty"] {
  width: 54px;
  min-width: 54px;
  padding-inline: 6px;
  text-align: right;
}

.detail-estimate-table .line-unit-column {
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  padding-inline: 3px;
  text-align: center;
  white-space: nowrap;
}

.detail-estimate-table .line-money-column {
  width: 80px;
  min-width: 80px;
  padding-inline: 3px;
  font-size: clamp(10px, 0.7vw, 12px);
  letter-spacing: -0.02em;
  color: #27352f;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.detail-estimate-table thead .line-money-column {
  text-align: right;
}

.detail-estimate-table .line-total-column {
  color: var(--accent);
  font-weight: 800;
}

.detail-estimate-table .line-remark-column {
  width: 125px;
  min-width: 125px;
}

.detail-estimate-table .line-remark-column textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  resize: vertical;
}

.detail-estimate-table .line-order-column {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  text-align: center;
}

.line-drag-handle {
  width: 40px;
  min-width: 40px;
  min-height: 34px;
  margin: 0;
  padding: 0;
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.line-drag-handle:active,
.is-line-dragging .line-drag-handle {
  cursor: grabbing;
}

.is-line-dragging {
  opacity: 0.48;
}

.detail-estimate-table tr.is-line-drop-before > td {
  box-shadow: inset 0 3px 0 var(--accent);
}

.detail-estimate-table tr.is-line-drop-after > td {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.line-card.is-line-drop-before {
  box-shadow: inset 0 3px 0 var(--accent);
}

.line-card.is-line-drop-after {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.line-group-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
}

.line-group-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

body[data-page="detail"] .line-group-title > strong {
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

body[data-page="detail"] .line-group-title > .muted {
  font-size: 12px;
  font-weight: 700;
}

.process-group-totals,
.process-group-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.process-group-totals > span {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.process-group-totals strong {
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.process-group-totals .process-total-amount strong {
  color: var(--accent);
}

.process-group-actions button {
  width: auto;
  min-height: 34px;
  margin: 0;
  padding: 0 10px;
  font-size: 11px;
}

.process-group-actions .process-add-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.process-group-actions .process-delete-selected-button {
  min-width: 82px;
}

.process-group-actions .process-delete-selected-button:disabled {
  color: #9a6b58;
  opacity: 0.48;
}

.historical-process-label {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff8ec;
  color: #8a6427;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.project-quote-open-button {
  width: auto;
  min-height: 28px;
  margin: 0;
  padding: 3px 8px;
  font-size: 10px;
  white-space: nowrap;
}

.project-quote-dialog .dialog-card {
  max-width: 560px;
}

.project-quote-cost-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.project-quote-amount-field {
  min-width: 0;
  margin-top: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.money-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-right: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.money-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(63, 115, 99, 0.12);
}

.project-quote-amount-input {
  min-height: 50px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.project-quote-amount-input:focus {
  outline: 0;
  box-shadow: none;
}

.money-input-wrap > span {
  color: var(--muted);
  font-weight: 700;
}

.project-quote-privacy-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

@media screen and (max-width: 640px) {
  .project-quote-cost-fields {
    grid-template-columns: 1fr;
  }
}

.line-group-row.is-hidden td {
  background: #f2f3ef;
}

.process-hidden-label {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.process-empty-row td,
.process-empty-row {
  padding: 16px 12px;
  color: var(--muted);
  text-align: center;
  background: #fcfdfb;
}

.line-card-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.line-card-totals {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media screen and (max-width: 1180px) {
  body[data-page="detail"] .detail-layout {
    display: block;
  }

  body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-group-head {
    grid-template-columns: minmax(160px, 1fr) auto;
  }

  .process-group-actions {
    grid-column: 1 / -1;
  }
}

@media screen and (max-width: 860px) {
  body[data-page="detail"] .detail-layout {
    display: block;
  }

  body[data-page="detail"] .topbar {
    align-items: flex-start;
  }

  .detail-header-actions {
    width: 100%;
    justify-items: stretch;
  }

  .line-selection-toolbar {
    justify-content: space-between;
  }

  .line-drag-handle {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  body[data-page="detail"] .detail-estimate-table {
    min-width: 1180px;
  }

  body[data-page="detail"] .detail-estimate-table .line-quantity-column [data-action="qty"] {
    width: 54px;
    min-width: 54px;
  }

  body[data-page="detail"] .detail-estimate-table .line-item-column {
    width: 175px;
    min-width: 175px;
    max-width: 190px;
  }

  .line-card-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .line-card-totals .summary-chip:last-child {
    grid-column: 1 / -1;
  }

  body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-card {
    grid-template-columns: 1fr;
  }
}

/* Keep these refinements after legacy responsive rules. */
body[data-page="login"] .login-shell, body[data-page="home"] .home-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); width: 100%; max-width: none; min-height: 100vh; min-height: 100svh; }
body[data-page="login"] .login-layout { display: grid; grid-template-columns: 1fr; width: 100%; max-width: none; min-height: 0; margin: 0; }
body[data-page="login"] .login-panel { align-self: stretch; width: 100%; min-height: 100%; }
body[data-page="home"] .home-layout { grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; min-height: 0; }
.home-topbar { min-height: auto; }
body[data-page="detail"] .detail-estimate-table { min-width: 1160px; }
.detail-estimate-table .line-order-column { position: sticky; left: 0; z-index: 5; width: 26px; min-width: 26px; max-width: 26px; padding-inline: 0; background: #fff; }
.detail-estimate-table .line-select-column { left: 26px; width: 36px; min-width: 36px; max-width: 36px; }
.detail-estimate-table .line-item-column { left: 62px; width: 190px; min-width: 190px; max-width: 190px; }
.detail-estimate-table .line-category-column { width: 120px; min-width: 120px; max-width: 120px; }
.detail-estimate-table .line-spec-column { width: 145px; min-width: 145px; max-width: 145px; }
.detail-estimate-table .line-unit-column { width: 34px; min-width: 34px; max-width: 34px; }
.detail-estimate-table .line-quantity-column { width: 48px; min-width: 48px; max-width: 48px; }
.detail-estimate-table .line-quantity-column [data-action="qty"] { width: 42px; min-width: 42px; }
.detail-estimate-table .line-unit-price-column { width: 62px; min-width: 62px; max-width: 62px; }
.detail-estimate-table .line-amount-column { width: 70px; min-width: 70px; max-width: 70px; }
.detail-estimate-table .line-total-column { width: 80px; min-width: 80px; max-width: 80px; }
.detail-estimate-table .line-remark-column { width: 155px; min-width: 155px; }
.line-drag-handle { width: 26px; min-width: 26px; min-height: 34px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; font-size: 22px; }
.line-drag-handle:hover, .line-drag-handle:focus-visible { border: 0; background: #eef3f0; box-shadow: none; }
.line-group-head { grid-template-columns: auto minmax(170px, 1fr) auto auto; }
.line-card-totals { grid-template-columns: repeat(6, minmax(0, 1fr)); }
body[data-page="print"] .print-document-header { grid-template-columns: minmax(0, 1fr) 58mm; grid-template-rows: auto auto; gap: 2mm 4mm; align-items: end; padding-bottom: 2.6mm; }
body[data-page="print"] .print-title-lockup { display: block; grid-column: 1; grid-row: 2; }
body[data-page="print"] .print-title-lockup h1 { margin: 0; font-size: 24pt; letter-spacing: 0.02em; }
body[data-page="print"] .print-header-right { display: contents; }
body[data-page="print"] .print-logo-lockup { display: flex; grid-column: 1 / -1; grid-row: 1; width: auto; max-width: 100%; align-items: center; justify-self: end; justify-content: flex-end; gap: 2mm; }
body[data-page="print"] .print-logo-lockup .print-brand-mark { width: 22.68mm; height: 22.68mm; flex: 0 0 22.68mm; }
body[data-page="print"] .print-logo-lockup .brand-mark-core { inset: 4.2mm; border-radius: 5.04mm; }
body[data-page="print"] .print-logo-lockup .brand-mark-dot { width: 4.2mm; height: 4.2mm; right: 3.36mm; bottom: 3.36mm; box-shadow: 0 0 0 1.26mm rgba(255, 255, 255, 0.72); }
body[data-page="print"] .print-logo-lockup .print-brand-mark.has-logo { width: 75.6mm; height: 22.68mm; flex-basis: 75.6mm; border: 0; border-radius: 0; box-shadow: none; }
body[data-page="print"] .print-logo-lockup .brand-logo-image { width: 100%; height: 100%; padding: 0; object-fit: contain; object-position: right center; }
body[data-page="print"] .print-logo-lockup .print-brand-mark.has-logo + .print-brand-word { display: none; }
body[data-page="print"] .print-logo-lockup .print-brand-word { font-size: 13.86pt; }
body[data-page="print"] .print-document-meta { grid-column: 2; grid-row: 2; width: 100%; gap: 0.35mm; }
body[data-page="print"] .print-document-meta > div { grid-template-columns: 17mm minmax(0, 1fr); gap: 1.5mm; }
body[data-page="print"] .print-document-meta dt, body[data-page="print"] .print-document-meta dd { line-height: 1.18; text-align: right; }
body[data-page="print"] .print-note-title, body[data-page="print"] .print-note-text { display: block; }
body[data-page="print"] .print-note-title { margin-bottom: 0.6mm; font-weight: 800; }
body[data-page="print"] .print-note-text { font-weight: 400; }

@media screen and (max-width: 980px) {
  .line-group-head { grid-template-columns: auto minmax(0, 1fr); }
  .process-group-totals, .process-group-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media screen and (max-width: 860px) {
  body[data-page="detail"] .detail-estimate-table { min-width: 1160px; }
  body[data-page="detail"] .detail-estimate-table .line-quantity-column [data-action="qty"] { width: 42px; min-width: 42px; }
  body[data-page="detail"] .detail-estimate-table .line-item-column { width: 190px; min-width: 190px; max-width: 190px; }
  .line-drag-handle { width: 26px; min-width: 26px; min-height: 44px; }
  .line-card-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.mobile-card-guide {
  display: none;
}

/* Mobile detail-entry workspace */
@media screen and (max-width: 860px) {
  body[data-page="detail"] {
    padding-bottom: calc(176px + env(safe-area-inset-bottom));
  }

  body[data-page="detail"] .brand-block > .muted {
    display: none;
  }

  body[data-page="detail"] .topbar-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="detail"] .topbar-actions #downloadPdfButton,
  body[data-page="detail"] .topbar-actions #saveEstimateButton {
    display: none;
  }

  body[data-page="detail"] .detail-estimate-tools {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="detail"] .detail-estimate-tools .compact-label {
    grid-column: 1 / -1;
  }

  body[data-page="detail"] .detail-estimate-tools > * {
    min-width: 0;
    margin: 0;
  }

  body[data-page="detail"] .customer-info-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="detail"] .customer-info-summary .customer-info-wide {
    grid-column: 1 / -1;
  }

  body[data-page="detail"] .customer-info-summary > div {
    padding: 10px 11px;
  }

  body[data-page="detail"] .metrics {
    display: flex;
    max-width: 100%;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 1px 1px 5px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body[data-page="detail"] .metrics::-webkit-scrollbar,
  body[data-page="detail"] .current-estimate-panel #quoteSummary::-webkit-scrollbar {
    display: none;
  }

  body[data-page="detail"] .metrics .metric {
    flex: 0 0 min(68vw, 230px);
    scroll-snap-align: start;
  }

  body[data-page="detail"] .current-estimate-panel #quoteSummary {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-card {
    display: flex;
    width: max-content;
    min-width: 100%;
    grid-template-columns: none;
    gap: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  body[data-page="detail"] .current-estimate-panel #quoteSummary .summary-row {
    width: min(42vw, 156px);
    min-width: min(42vw, 156px);
    scroll-snap-align: start;
  }

  body[data-page="detail"] .detail-sheet-section {
    scroll-margin-top: 8px;
  }

  body[data-page="detail"] .detail-sheet-section > .table-wrap,
  body[data-page="detail"] .detail-scroll-hint {
    display: none;
  }

  body[data-page="detail"] .mobile-card-guide {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 11px;
    padding: 10px 11px;
    border: 1px solid rgba(63, 115, 99, 0.18);
    border-radius: 12px;
    background: rgba(239, 247, 242, 0.94);
    color: #355e51;
    font-size: 11px;
    line-height: 1.5;
  }

  body[data-page="detail"] .mobile-card-guide strong {
    flex: 0 0 auto;
    font-size: 12px;
    white-space: nowrap;
  }

  body[data-page="detail"] .mobile-line-cards {
    display: grid;
    gap: 12px;
  }

  body[data-page="detail"] .line-card-group {
    gap: 9px;
    margin: 0;
    padding: 10px;
    border: 1px solid rgba(26, 33, 42, 0.08);
    border-radius: 18px;
    background: #f4f7f4;
  }

  body[data-page="detail"] .line-card-group + .line-card-group {
    margin-top: 2px;
  }

  body[data-page="detail"] .line-card-group > .line-group-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding: 10px;
    border: 1px solid rgba(26, 33, 42, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
  }

  body[data-page="detail"] .line-card-group .line-group-title {
    grid-column: 1;
    grid-row: 1;
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  body[data-page="detail"] .line-card-group .line-group-title > strong {
    font-size: 19px;
    line-height: 1.25;
  }

  body[data-page="detail"] .line-card-group .process-group-leading-actions {
    display: flex;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  body[data-page="detail"] .line-card-group .process-group-leading-actions button {
    min-height: 40px;
    margin: 0;
  }

  body[data-page="detail"] .line-card-group .process-group-totals {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 11px;
  }

  body[data-page="detail"] .line-card-group .process-group-actions {
    display: grid;
    grid-column: 1 / -1;
    grid-row: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body[data-page="detail"] .line-card-group .process-group-actions button {
    width: 100%;
    min-height: 40px;
  }

  body[data-page="detail"] .line-card-group .process-group-footer {
    padding-top: 3px;
  }

  body[data-page="detail"] .line-card-group .process-group-footer-actions {
    width: 100%;
    justify-content: flex-end;
  }

  body[data-page="detail"] .line-card-group .process-group-footer-actions button {
    min-height: 44px;
  }

  body[data-page="detail"] .process-memo-card .process-memo-editor {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body[data-page="detail"] .process-memo-card .process-memo-actions {
    justify-self: end;
  }

  body[data-page="detail"] .line-selection-toolbar {
    min-height: 44px;
    padding: 8px 10px;
  }

  body[data-page="detail"] .line-selection-toolbar > span:not(.line-reorder-status) {
    display: none;
  }

  body[data-page="detail"] .line-card {
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.045);
  }

  body[data-page="detail"] .line-card-head {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 12px;
  }

  body[data-page="detail"] .line-card-leading {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: flex-start;
    gap: 8px;
  }

  body[data-page="detail"] .line-card .line-drag-handle {
    width: 38px;
    min-width: 38px;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #f6f8f6;
  }

  body[data-page="detail"] .line-card-title {
    min-width: 0;
    flex: 1 1 auto;
    gap: 4px;
  }

  body[data-page="detail"] .line-card-meta {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
  }

  body[data-page="detail"] .line-card-category {
    min-width: 0;
    overflow: hidden;
    font-size: 10px;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-page="detail"] .line-card-name {
    display: block;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 15px;
    line-height: 1.35;
  }

  body[data-page="detail"] .line-card-spec-preview {
    display: block;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-page="detail"] .line-card-primary-total {
    flex: 0 0 min(29vw, 112px);
  }

  body[data-page="detail"] .line-card-primary-total .summary-chip {
    min-height: 58px;
    padding: 8px 9px;
    border-radius: 12px;
    text-align: right;
  }

  body[data-page="detail"] .line-card-primary-total .summary-chip strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
  }

  body[data-page="detail"] .line-card-status-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: -3px 0 10px 46px;
  }

  body[data-page="detail"] .line-card-status-actions:empty {
    display: none;
  }

  body[data-page="detail"] .line-card-status-actions .project-quote-open-button {
    width: auto;
    min-height: 38px;
    margin: 0;
  }

  body[data-page="detail"] .line-card-core-fields {
    display: grid;
    gap: 9px;
  }

  body[data-page="detail"] .line-card-core-fields input,
  body[data-page="detail"] .line-card-core-fields select,
  body[data-page="detail"] .line-card-core-fields textarea {
    margin-top: 5px;
  }

  body[data-page="detail"] .line-card-quantity-row {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(92px, 0.7fr);
    gap: 9px;
  }

  body[data-page="detail"] .line-card-unit-field input {
    color: #53605b;
    text-align: center;
    -webkit-text-fill-color: #53605b;
    opacity: 1;
  }

  body[data-page="detail"] .line-card-qty-field input {
    border-color: rgba(63, 115, 99, 0.34);
    background: #f1f8f4;
    color: var(--accent);
    font-size: 20px;
    font-weight: 800;
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  body[data-page="detail"] .line-card-remark-field textarea {
    min-height: 70px;
    resize: vertical;
  }

  body[data-page="detail"] .line-card-cost-details {
    margin-top: 10px;
    border-top: 1px solid var(--line);
  }

  body[data-page="detail"] .line-card-cost-details > summary {
    display: flex;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
  }

  body[data-page="detail"] .line-card-cost-details > summary::-webkit-details-marker {
    display: none;
  }

  body[data-page="detail"] .line-card-cost-details > summary::before {
    content: "+";
    display: grid;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    place-items: center;
    border-radius: 50%;
    background: #edf3ef;
    color: var(--accent);
    font-size: 17px;
  }

  body[data-page="detail"] .line-card-cost-details[open] > summary::before {
    content: "−";
  }

  body[data-page="detail"] .line-card-cost-details > summary > span:first-of-type {
    margin-right: auto;
  }

  body[data-page="detail"] .line-card-combined-unit {
    display: grid;
    justify-items: end;
    gap: 2px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
  }

  body[data-page="detail"] .line-card-combined-unit strong {
    color: var(--text);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
  }

  body[data-page="detail"] .line-card-cost-groups {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    margin: 0 0 2px;
  }

  body[data-page="detail"] .line-card-cost-group {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }

  body[data-page="detail"] .line-card-cost-group > strong {
    display: block;
    padding: 7px 8px;
    border-bottom: 1px solid var(--line);
    background: #eef4f0;
    color: #253c34;
    font-size: 11px;
    text-align: center;
  }

  body[data-page="detail"] .line-card-cost-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="detail"] .line-card-cost-pair .summary-chip {
    min-width: 0;
    padding: 9px 7px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  body[data-page="detail"] .line-card-cost-pair .summary-chip + .summary-chip {
    border-left: 1px solid var(--line);
  }

  body[data-page="detail"] .mobile-total-bar {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 6px;
    padding: 8px;
    border-radius: 17px;
  }

  body[data-page="detail"] .mobile-total-copy {
    padding: 7px 8px;
  }

  body[data-page="detail"] .mobile-total-actions {
    gap: 6px;
  }

  body[data-page="detail"] #estimateSaveStatus {
    bottom: calc(128px + env(safe-area-inset-bottom));
  }
}
/* End mobile detail-entry workspace */

/* Estimate review markings and selected totals */
.line-selection-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.line-change-menu-wrap,
.selected-total-menu {
  position: relative;
}

.line-change-menu,
.selected-total-menu-items {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  min-width: 118px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.line-change-menu[hidden] {
  display: none;
}

.line-change-menu button,
.selected-total-menu-items button {
  min-height: 34px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
  text-align: left;
}

.line-change-menu button:hover,
.line-change-menu button:focus-visible,
.selected-total-menu-items button:hover,
.selected-total-menu-items button:focus-visible {
  background: var(--accent-soft);
}

.estimate-change-summary {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f4ea;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.estimate-change-summary[hidden] {
  display: none;
}

.estimate-change-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.detail-estimate-table tr.is-estimate-highlighted > td,
.detail-estimate-table tr.is-estimate-change-added > td,
.detail-estimate-table tr.is-estimate-change-modified > td {
  background: #faf7ed;
}

.detail-estimate-table tr.is-estimate-change-deleted > td {
  background: #f0f1ee;
  color: var(--muted);
}

.detail-estimate-table tr.is-estimate-change-deleted select,
.detail-estimate-table tr.is-estimate-change-deleted input:not([type="checkbox"]),
.detail-estimate-table tr.is-estimate-change-deleted textarea {
  color: var(--muted);
  text-decoration: line-through;
}

.detail-estimate-table tr.is-estimate-change-deleted .line-money-column,
.detail-estimate-table tr.is-estimate-change-deleted .line-unit-column {
  text-decoration: line-through;
}

.line-card.is-estimate-highlighted,
.line-card.is-estimate-change-added,
.line-card.is-estimate-change-modified {
  border-color: rgba(146, 124, 75, 0.28);
  background: #faf7ed;
}

.line-card.is-estimate-change-deleted {
  border-color: var(--line-strong);
  background: #f0f1ee;
  color: var(--muted);
}

.line-card.is-estimate-change-deleted .line-card-name,
.line-card.is-estimate-change-deleted .line-card-spec-preview,
.line-card.is-estimate-change-deleted .line-card-core-fields input,
.line-card.is-estimate-change-deleted .line-card-core-fields select,
.line-card.is-estimate-change-deleted .line-card-core-fields textarea,
.line-card.is-estimate-change-deleted .summary-chip strong {
  color: var(--muted);
  text-decoration: line-through;
}

.selected-total-row > td {
  border-top: 1px solid var(--line-strong);
  background: #f4f7f4;
  color: var(--text);
}

.selected-total-row > td:first-child {
  padding-left: 16px;
}

.selected-total-action-cell {
  text-align: right;
}

.selected-total-menu {
  display: inline-block;
}

.selected-total-menu > summary {
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.selected-total-menu > summary::-webkit-details-marker {
  display: none;
}

.selected-total-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line-strong);
  background: #f4f7f4;
  font-size: 12px;
}

.selected-total-card > span {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

body[data-page="print"] .print-change-summary {
  display: flex;
  gap: 3mm;
  align-items: baseline;
  margin-top: 3mm;
  padding: 2mm 3mm;
  border-top: 0.25mm solid var(--line-strong);
  border-bottom: 0.2mm solid var(--line);
  background: #faf7ed;
  font-size: 7.5pt;
}

body[data-page="print"] .print-change-summary strong {
  color: var(--accent);
}

body[data-page="print"] .print-change-badge {
  display: inline-block;
  margin-right: 0.6mm;
  color: var(--accent);
  font-size: 5pt;
  font-weight: 800;
  text-decoration: none;
}

body[data-page="print"] .print-detail-table-row.is-estimate-highlighted > .print-detail-cell,
body[data-page="print"] .print-detail-table-row.is-estimate-change-added > .print-detail-cell,
body[data-page="print"] .print-detail-table-row.is-estimate-change-modified > .print-detail-cell {
  background: #faf7ed;
}

body[data-page="print"] .print-detail-table-row.is-estimate-change-deleted > .print-detail-cell {
  background: #f0f1ee;
  color: #5f6863;
}

body[data-page="print"] .print-detail-table-row.is-estimate-change-deleted .print-cell-value {
  color: #5f6863;
  text-decoration: line-through;
}

body[data-page="print"] .print-selected-total-row {
  break-inside: avoid;
}

body[data-page="print"] .print-selected-total-row > .print-detail-cell {
  border-top: 0.3mm solid var(--line-strong);
  background: #f4f7f4;
  font-weight: 800;
}

body[data-page="print"] .print-selected-total-label {
  grid-column: 1 / span 9;
  padding-left: 1.8mm;
}

body[data-page="print"] .print-selected-total-amount {
  grid-column: 10;
}

body[data-page="print"] .print-selected-total-remark {
  grid-column: 11;
}

@media screen and (max-width: 860px) {
  body[data-page="detail"] .detail-selection-sticky {
    top: calc(var(--it-review-banner-height, 0px) + max(6px, env(safe-area-inset-top)));
  }

  body[data-page="detail"] .line-selection-toolbar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  body[data-page="detail"] .line-selection-actions {
    flex: 1 1 100%;
  }

  body[data-page="detail"] .line-selection-actions > button,
  body[data-page="detail"] .line-change-menu-wrap,
  body[data-page="detail"] .line-change-menu-wrap > button {
    flex: 1 1 0;
    width: 100%;
  }

  body[data-page="detail"] .project-quote-status-row {
    flex-wrap: wrap;
  }
}

@media print {
  body[data-page="print"] .print-change-summary,
  body[data-page="print"] .print-detail-table-row.is-estimate-highlighted > .print-detail-cell,
  body[data-page="print"] .print-detail-table-row.is-estimate-change-added > .print-detail-cell,
  body[data-page="print"] .print-detail-table-row.is-estimate-change-modified > .print-detail-cell,
  body[data-page="print"] .print-detail-table-row.is-estimate-change-deleted > .print-detail-cell,
  body[data-page="print"] .print-selected-total-row > .print-detail-cell {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Mobile workflow optimization: 360-430px admin, margin and detail entry. */
body[data-page="margin"] {
  overflow-x: clip;
}

.admin-nav-dropdown {
  max-width: calc(100vw - 20px);
  max-height: calc(100dvh - 20px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media screen and (max-width: 640px) {
  body[data-page="detail"] .app-dialog {
    width: calc(100vw - max(10px, env(safe-area-inset-left)) - max(10px, env(safe-area-inset-right)));
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  body[data-page="detail"] .app-dialog .dialog-card {
    max-width: none;
    padding: 17px;
  }

  body[data-page="detail"] .app-dialog .dialog-header {
    gap: 10px;
    margin-bottom: 14px;
  }

  body[data-page="detail"] .app-dialog .dialog-header > div,
  body[data-page="detail"] .app-dialog .dialog-description {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body[data-page="detail"] .app-dialog .dialog-close {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  body[data-page="detail"] .app-dialog .dialog-description {
    margin-bottom: 13px;
    line-height: 1.55;
  }

  body[data-page="detail"] .app-dialog .dialog-actions {
    position: sticky;
    z-index: 2;
    bottom: -17px;
    margin: 13px -17px -17px;
    padding: 10px 17px max(17px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -10px 22px rgba(15, 23, 42, 0.06);
  }

  body[data-page="detail"] .app-dialog .dialog-actions button {
    min-width: 0;
    min-height: 48px;
  }

  body[data-page="detail"] .estimate-refresh-option {
    min-height: 76px;
    align-items: center;
    padding: 13px 14px;
  }

  body[data-page="detail"] .estimate-refresh-option input {
    width: 24px;
    min-width: 24px;
    height: 24px;
    min-height: 24px;
    margin-top: 0;
  }

  body[data-page="detail"] .estimate-refresh-dialog .dialog-actions {
    grid-template-columns: minmax(84px, 0.65fr) minmax(0, 1.35fr);
  }

  body[data-page="detail"] .estimate-refresh-dialog .dialog-actions button {
    padding-inline: 10px;
  }

  body[data-page="detail"] .project-quote-cost-fields {
    gap: 14px;
  }

  body[data-page="detail"] .project-quote-dialog .money-input-wrap {
    min-height: 56px;
  }

  body[data-page="detail"] .project-quote-dialog .project-quote-amount-input {
    min-width: 0;
    min-height: 54px;
    font-size: clamp(21px, 6.5vw, 25px);
  }

  body[data-page="detail"] .line-card-status-actions .project-quote-open-button {
    min-height: 44px;
  }

  body[data-page="detail"]:has(.mobile-total-actions [data-mobile-estimate-action="reservation"]:not([hidden]), .mobile-total-actions [data-mobile-estimate-action="workflow"]:not([hidden])) {
    padding-bottom: calc(230px + env(safe-area-inset-bottom));
  }

  body[data-page="detail"]:has(.mobile-total-actions [data-mobile-estimate-action="reservation"]:not([hidden]), .mobile-total-actions [data-mobile-estimate-action="workflow"]:not([hidden])) #estimateSaveStatus {
    bottom: calc(182px + env(safe-area-inset-bottom));
  }

  body[data-page="detail"] .mobile-total-bar {
    left: calc(8px + env(safe-area-inset-left));
    right: calc(8px + env(safe-area-inset-right));
  }

  body:not([data-page="login"]) .topbar-actions > button,
  body:not([data-page="login"]) .topbar-actions > .button-link,
  body[data-page="home"] .home-account-actions .admin-session-badge {
    min-height: 44px;
  }

  body[data-page="detail"] .page-nav .nav-chip,
  body[data-page="detail"] .line-card-group .process-group-leading-actions button,
  body[data-page="detail"] .line-card-group .process-add-button {
    min-width: 44px;
    min-height: 44px;
  }

  body[data-page="detail"] .line-card-group .process-add-button,
  body[data-page="detail"] .line-card .line-drag-handle {
    width: 44px;
    min-width: 44px;
  }

  .admin-nav-dropdown {
    width: calc(100vw - 20px);
    min-width: 0;
    padding: 8px;
    border-radius: 15px;
  }

  .admin-nav-dropdown a {
    min-height: 48px;
    padding-inline: 14px;
    font-size: 14px;
  }

  body[data-page="login"] .login-shell {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  body[data-page="login"] .login-topbar {
    margin-bottom: 10px;
  }

  body[data-page="login"] .login-panel {
    min-height: auto;
    padding: 18px 15px;
  }

  body[data-page="login"] .login-panel-header {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
  }

  body[data-page="login"] .login-account-stack {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    justify-self: stretch;
    gap: 10px;
  }

  body[data-page="login"] .login-account-stack .login-panel-brand {
    min-width: 0;
    margin: 0;
    justify-content: flex-start;
  }

  body[data-page="login"] .login-panel-brand-logo {
    max-width: min(210px, 62vw);
    height: 38px;
  }

  body[data-page="login"] .login-preference-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
  }

  body[data-page="login"] .remember-id-help {
    padding-left: 29px;
    font-size: 11px;
  }

  body[data-page="margin"] .margin-management-layout,
  body[data-page="margin"] .margin-accordion {
    gap: 8px;
  }

  body[data-page="margin"] .margin-accordion-section {
    border-radius: 17px;
  }

  body[data-page="margin"] .margin-accordion-section:has(> .margin-accordion-trigger[aria-expanded="true"]) {
    overflow: visible;
  }

  body[data-page="margin"] .margin-accordion-trigger {
    min-height: 76px;
    padding: 14px;
  }

  body[data-page="margin"] .margin-accordion-trigger strong {
    font-size: 19px;
  }

  body[data-page="margin"] .margin-accordion-trigger > .muted {
    font-size: 12px;
    line-height: 1.45;
  }

  body[data-page="margin"] .margin-accordion-panel {
    padding: 2px 10px 12px;
  }

  body[data-page="margin"] .margin-global-batch-card {
    margin: 12px 0;
    padding: 12px;
  }

  body[data-page="margin"] .process-margin-card {
    padding: 12px;
    border-radius: 15px;
  }

  body[data-page="margin"] .process-margin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  body[data-page="margin"] .estimate-margin-bulk-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 11px;
  }

  body[data-page="margin"] .estimate-margin-bulk-tools > strong,
  body[data-page="margin"] .estimate-margin-bulk-tools > button {
    grid-column: 1 / -1;
    width: 100%;
  }

  body[data-page="margin"] .estimate-margin-bulk-tools .compact-label {
    width: auto;
    min-width: 0;
  }

  body[data-page="margin"] .process-margin-savebar,
  body[data-page="margin"] .item-margin-savebar {
    position: sticky;
    top: max(8px, env(safe-area-inset-top));
    bottom: auto;
    z-index: 18;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 12px -2px 0;
    padding: 10px;
    border: 1px solid rgba(63, 115, 99, 0.2);
    border-radius: 14px;
    background: rgba(253, 253, 249, 0.97);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
  }

  body[data-page="margin"] .process-margin-savebar .margin-action-row,
  body[data-page="margin"] .item-margin-savebar .margin-action-row {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  body[data-page="margin"] .item-margin-table,
  body[data-page="margin"] #estimateMarginPanel table {
    display: block;
    width: 100%;
    min-width: 0;
    background: transparent;
  }

  body[data-page="margin"] .table-wrap .item-margin-table {
    min-width: 0;
  }

  body[data-page="margin"] .item-margin-table thead,
  body[data-page="margin"] #estimateMarginPanel table thead {
    display: none;
  }

  body[data-page="margin"] .item-margin-table tbody,
  body[data-page="margin"] #estimateMarginPanel table tbody {
    display: grid;
    gap: 10px;
  }

  body[data-page="margin"] .item-margin-table tr,
  body[data-page="margin"] #estimateMarginPanel table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.045);
  }

  body[data-page="margin"] .item-margin-table td,
  body[data-page="margin"] #estimateMarginPanel table td {
    display: grid;
    min-width: 0;
    align-content: start;
    gap: 5px;
    padding: 0;
    border: 0;
    color: var(--text);
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body[data-page="margin"] .item-margin-table td::before,
  body[data-page="margin"] #estimateMarginPanel table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
  }

  body[data-page="margin"] .item-margin-table td:not([data-label])::before,
  body[data-page="margin"] #estimateMarginPanel table td:not([data-label])::before {
    display: none;
  }

  body[data-page="margin"] .item-margin-table input,
  body[data-page="margin"] #estimateMarginPanel table input,
  body[data-page="margin"] #estimateMarginPanel table textarea {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    margin: 0;
  }

  body[data-page="margin"] .margin-undo-button {
    min-height: 44px;
  }

  body[data-page="margin"] .item-margin-table td:nth-child(7) {
    grid-column: 1 / -1;
  }

  body[data-page="margin"] .item-margin-table tr[hidden],
  body[data-page="margin"] #estimateMarginPanel table tr[hidden] {
    display: none;
  }

  body[data-page="margin"] .item-margin-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body[data-page="margin"] .item-margin-basis-group {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  body[data-page="margin"] .item-margin-reset {
    width: 100%;
    min-height: 44px;
    margin-top: 3px;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(4) {
    grid-column: 1;
    grid-row: 3;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(5) {
    grid-column: 2;
    grid-row: 3;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(6) {
    grid-column: 1 / -1;
    grid-row: 4;
    padding: 10px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }

  body[data-page="margin"] #estimateMarginPanel table td:nth-child(7) {
    grid-column: 1 / -1;
    grid-row: 5;
  }

  body[data-page="margin"] #estimateMarginPanel table .empty-row {
    grid-column: 1 / -1;
    grid-row: auto;
    padding: 18px 8px;
    text-align: center;
  }
}

@media screen and (max-width: 430px) {
  body[data-page="home"] .home-account-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-page="home"] #homeAccountLink {
    grid-column: 1 / -1;
  }

  body[data-page="home"] .home-admin-menu,
  body[data-page="home"] .home-admin-link,
  body[data-page="home"] #homeLogoutButton {
    width: 100%;
  }

  body[data-page="home"] .home-status-filter {
    min-height: 64px;
    padding: 11px 12px;
  }

  body[data-page="home"] .home-primary-action,
  body[data-page="home"] .home-secondary-action {
    min-height: 92px;
    padding: 18px;
  }

  body[data-page="home"] .home-estimate-card {
    padding: 12px;
  }

  body[data-page="detail"] .line-selection-toolbar[data-selection-active="false"] #highlightSelectedLinesButton,
  body[data-page="detail"] .line-selection-toolbar[data-selection-active="false"] .line-change-menu-wrap,
  body[data-page="detail"] .line-selection-toolbar[data-selection-active="false"] #createSelectedTotalButton,
  body[data-page="detail"] .line-selection-toolbar .estimate-undo-button:disabled {
    display: none;
  }

  body[data-page="detail"] .line-selection-toolbar[data-selection-active="false"] .line-selection-actions {
    flex: 0 0 auto;
  }

  body[data-page="detail"] .line-selection-toolbar[data-selection-active="true"] .line-selection-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body[data-page="detail"] .line-selection-toolbar[data-selection-active="true"] .line-selection-actions > button,
  body[data-page="detail"] .line-selection-toolbar[data-selection-active="true"] .line-change-menu-wrap,
  body[data-page="detail"] .line-selection-toolbar[data-selection-active="true"] .line-change-menu-wrap > button {
    width: 100%;
    min-width: 0;
  }

  body[data-page="detail"] .detail-sheet-section:has(.line-selection-toolbar[data-selection-active="true"]) .line-card [data-action] {
    scroll-margin-top: calc(var(--it-review-banner-height, 0px) + env(safe-area-inset-top) + 150px);
  }

  body[data-page="detail"] .line-select-all,
  body[data-page="detail"] .line-card-select {
    min-height: 44px;
  }

  body[data-page="detail"] .line-card-select {
    padding-right: 6px;
  }

  body[data-page="detail"] .line-card-select input {
    width: 22px;
    height: 22px;
    min-height: 22px;
  }

  body[data-page="detail"] .selected-total-card {
    grid-template-columns: minmax(0, 1fr) auto 44px;
    gap: 8px;
    min-height: 60px;
    padding: 8px 6px 8px 12px;
    scroll-margin-bottom: 176px;
  }

  body[data-page="detail"] .selected-total-card > strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  body[data-page="detail"] .selected-total-card > span {
    white-space: nowrap;
  }

  body[data-page="detail"] .selected-total-menu > summary {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    background: #fff;
  }

  body[data-page="detail"] .selected-total-menu-items {
    min-width: 156px;
    max-width: calc(100vw - 32px);
  }

  body[data-page="detail"] .selected-total-menu-items button,
  body[data-page="detail"] .line-change-menu button {
    min-height: 44px;
    font-size: 12px;
  }

  body[data-page="detail"] .line-card-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: start;
  }

  body[data-page="detail"] .line-card-head-actions {
    display: contents;
  }

  body[data-page="detail"] .line-card-leading {
    grid-column: 1;
    grid-row: 1;
  }

  body[data-page="detail"] .line-card-delete-button {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }

  body[data-page="detail"] .line-card-primary-total {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    flex: none;
  }

  body[data-page="detail"] .line-card-primary-total .summary-chip {
    display: flex;
    min-height: 48px;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  body[data-page="detail"] .line-card-primary-total .summary-chip span {
    margin: 0;
  }

  body[data-page="detail"] .line-card-status-actions {
    margin-left: 0;
  }

  body[data-page="detail"] .line-card-quantity-row {
    grid-template-columns: minmax(0, 1fr) minmax(80px, 0.55fr);
  }

  body[data-page="detail"] .mobile-total-copy strong {
    overflow: hidden;
    font-size: clamp(11px, 3.35vw, 14px);
    text-overflow: ellipsis;
  }
}
/* End mobile workflow optimization. */

/* Estimate settings mobile optimization */
@media screen and (max-width: 640px) {
  body:has(.estimate-settings-dialog[open]) {
    overflow: hidden;
  }

  .estimate-settings-dialog {
    width: calc(100vw - max(10px, env(safe-area-inset-left)) - max(10px, env(safe-area-inset-right)));
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
    overflow: hidden;
    border-radius: 16px;
  }

  .estimate-settings-dialog-card {
    max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
    padding: 14px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-bottom: 138px;
    -webkit-overflow-scrolling: touch;
  }

  .estimate-settings-dialog .dialog-header {
    position: sticky;
    z-index: 4;
    top: -14px;
    gap: 10px;
    margin: -14px -14px 0;
    padding: 14px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  .estimate-settings-dialog .dialog-header > div {
    min-width: 0;
  }

  .estimate-settings-dialog .dialog-header h2 {
    font-size: 20px;
    overflow-wrap: anywhere;
  }

  .estimate-settings-dialog .dialog-close {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .estimate-settings-dialog .dialog-description {
    margin: 12px 2px 0;
    font-size: 14px;
    line-height: 1.55;
    overflow-wrap: anywhere;
  }

  .estimate-settings-section {
    margin-top: 10px;
    padding: 12px;
    border-radius: 14px;
  }

  .estimate-settings-section-header {
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }

  .estimate-settings-section-header h3 {
    font-size: 16px;
  }

  .estimate-settings-section-header .short-button {
    min-width: 88px;
    min-height: 44px;
    margin: 0;
  }

  .estimate-settings-adjustments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 11px;
  }

  .estimate-settings-adjustments label {
    min-width: 0;
    min-height: 48px;
    padding: 9px 10px;
    font-size: 14px;
    line-height: 1.35;
  }

  .estimate-settings-adjustments input {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
  }

  .estimate-settings-dialog .dialog-form-grid {
    gap: 10px;
  }

  .estimate-settings-dialog input:not([type="checkbox"]),
  .estimate-settings-dialog select,
  .estimate-settings-dialog textarea {
    min-height: 48px;
    font-size: 16px;
  }

  .estimate-settings-dialog input,
  .estimate-settings-dialog select,
  .estimate-settings-dialog textarea,
  .estimate-settings-dialog button {
    touch-action: manipulation;
  }

  .estimate-settings-term-list {
    max-height: none;
    padding-right: 0;
    overflow: visible;
  }

  .estimate-settings-dialog .quotation-term-row {
    gap: 8px;
    padding: 10px;
  }

  .estimate-settings-dialog .quotation-term-row textarea {
    min-height: 96px;
  }

  .estimate-settings-dialog .quotation-term-row .short-button {
    width: 100%;
    min-height: 44px;
  }

  .estimate-settings-dialog .dialog-feedback {
    margin: 10px 2px 0;
  }

  .estimate-settings-dialog-actions {
    position: sticky;
    z-index: 5;
    bottom: -14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 14px -14px -14px;
    padding: 10px 14px max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -10px 22px rgba(15, 23, 42, 0.08);
  }

  .estimate-settings-dialog-actions > button {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .estimate-settings-dialog-actions .dialog-actions,
  body[data-page="detail"] .estimate-settings-dialog-actions .dialog-actions {
    position: static;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .estimate-settings-dialog-actions .dialog-actions button {
    min-width: 0;
    min-height: 48px;
  }
}

@media screen and (max-width: 430px) {
  .estimate-settings-dialog-card {
    padding: 12px;
    scroll-padding-bottom: 136px;
  }

  .estimate-settings-dialog .dialog-header {
    top: -12px;
    margin: -12px -12px 0;
    padding: 12px;
  }

  .estimate-settings-section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .estimate-settings-section-header .short-button {
    width: 100%;
  }

  .estimate-settings-dialog-actions {
    bottom: -12px;
    margin: 12px -12px -12px;
    padding-inline: 12px;
  }
}
/* End estimate settings mobile optimization */

/* Customer and site folders share the existing EASE working surface. */
.customer-folder{border:1px solid var(--line,#dce2e8);border-radius:14px;margin:14px 0;background:var(--surface,#fff);overflow:hidden}
.customer-folder>summary{cursor:pointer;display:flex;align-items:center;justify-content:space-between;gap:20px;padding:20px;list-style:none}
.customer-folder>summary::after{content:'＋';font-size:22px;color:#59616e}.customer-folder[open]>summary::after{content:'−'}
.customer-folder-heading{display:grid;gap:6px;flex:1;min-width:0}.customer-folder-heading>strong{font-size:20px}.customer-folder-heading span,.customer-folder-heading small{overflow-wrap:anywhere}.customer-folder-heading small{font-size:14px;color:#657082}
.customer-folder-counts{display:grid;gap:7px;text-align:right;font-size:14px}.customer-folder-counts b{font-size:18px}.customer-folder-body{padding:0 18px 18px;border-top:1px solid #e6e9ee}.customer-folder-actions{display:flex;flex-wrap:wrap;gap:8px;padding:15px 0}.customer-folder-body .saved-card{margin-top:12px}.customer-folder-actions a{padding:10px 14px;text-decoration:none;border:1px solid #dce2e8;border-radius:9px}
.customer-folder-picker{padding:14px;border:1px solid #dce2e8;border-radius:10px;margin:12px 0 18px}.customer-folder-picker label{display:grid;gap:7px}.customer-folder-results{max-height:210px;overflow:auto;margin:8px 0}.customer-folder-option{display:grid!important;gap:5px;width:100%;text-align:left;background:#f6f8fa!important;color:#202631!important;margin:5px 0;padding:12px!important}.customer-folder-option span{font-size:14px;font-weight:400}.customer-folder-picker p{font-size:14px}
@media(max-width:640px){.customer-folder>summary{gap:12px;padding:16px;align-items:flex-start;flex-wrap:wrap}.customer-folder-heading{flex-basis:75%}.customer-folder-counts{text-align:left;grid-template-columns:1fr 1fr;width:100%}.customer-folder-counts b{grid-column:1/-1}.customer-folder>summary::after{position:absolute;right:30px}.customer-folder-body{padding:0 12px 12px}.customer-folder-actions a{flex:1 1 45%;text-align:center;font-size:14px}}

/* Compact guidance: status messages remain visible when populated. */
.item-margin-status:empty,
.document-help:empty,
.template-preview-heading .muted:empty {
  display: none;
}
.permission-guide {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}
.permission-guide summary {
  cursor: pointer;
}
.permission-guide p {
  margin: 8px 0 0;
}

/* Keep the active estimate field visible for mouse, touch, and keyboard entry. */
@media screen {
  body:is([data-page="detail"], [data-page="summary"]) {
    --entry-focus: #3f7363;
    --entry-focus-row: #edf4ef;
    --entry-focus-rail: #557d6d;
  }

  input[data-action="qty"][type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
  }

  input[data-action="qty"][type="number"]::-webkit-inner-spin-button,
  input[data-action="qty"][type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  body:is([data-page="detail"], [data-page="summary"]) :is(input, select, textarea):focus,
  body:is([data-page="detail"], [data-page="summary"]) :is(button, a, summary):focus-visible {
    outline: 2px solid var(--entry-focus);
    outline-offset: -1px;
    box-shadow: none;
  }

  body:is([data-page="detail"], [data-page="summary"]) :is(button, a, summary):focus-visible,
  body:is([data-page="detail"], [data-page="summary"]) :is(input[type="checkbox"], input[type="radio"]):focus {
    outline-offset: 2px;
  }

  body:is([data-page="detail"], [data-page="summary"]) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea):focus {
    border-color: var(--entry-focus);
    background-color: #fff;
    caret-color: var(--entry-focus);
  }

  /* Preserve explicit estimate highlight/change colors while tracking entry. */
  body[data-page="detail"] .detail-estimate-table tr[data-line-row]:focus-within:not(:is(.is-estimate-highlighted, .is-estimate-change-added, .is-estimate-change-modified, .is-estimate-change-deleted)) > td {
    background-color: var(--entry-focus-row);
  }

  body[data-page="detail"] .detail-estimate-table tr[data-line-row]:focus-within > td:first-child {
    box-shadow: inset 3px 0 0 var(--entry-focus-rail);
  }

  body[data-page="detail"] .line-card[data-line-card]:focus-within:not(:is(.is-estimate-highlighted, .is-estimate-change-added, .is-estimate-change-modified, .is-estimate-change-deleted)) {
    background-color: var(--entry-focus-row);
  }

  body[data-page="detail"] .line-card[data-line-card]:focus-within {
    box-shadow: inset 3px 0 0 var(--entry-focus-rail);
  }

  body:is([data-page="detail"], [data-page="summary"]) :is(input, select, textarea)::selection {
    color: #fff;
    background-color: var(--entry-focus);
  }
}
