:root {
  --ink: #111827;
  --muted: #566273;
  --accent: #0f4c81;
  --accent-2: #087c8f;
  --line: #334155;
  --fill: #f7e9a6;
  --paper: #ffffff;
  --surface: #f3f4f6;
  --field: #ffffff;
  --panel: #ffffff;
  --border: #d1d5db;
  --button: #1f2937;
  --button-border: #111827;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
}

body.auth-locked {
  overflow: hidden;
}

body.is-resizing-shell {
  cursor: col-resize;
  user-select: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(420px, clamp(500px, var(--editor-width, 44vw), 720px)) 8px minmax(390px, 1fr);
  gap: 10px;
  min-height: 100vh;
  padding: 10px;
  align-items: start;
}

.shell-resizer {
  width: 8px;
  min-height: calc(100vh - 40px);
  align-self: stretch;
  position: sticky;
  top: 20px;
  border-radius: 999px;
  cursor: col-resize;
  touch-action: none;
}

.shell-resizer::before {
  content: "";
  display: block;
  width: 3px;
  height: 100%;
  min-height: 120px;
  margin: 0 auto;
  border-radius: 999px;
  background: #cbd5e1;
}

.shell-resizer:hover::before,
.shell-resizer.is-dragging::before,
.shell-resizer:focus-visible::before {
  background: var(--accent-2);
}

.editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  container-type: inline-size;
}

.editor-header {
  display: grid;
  gap: 6px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor h1 {
  margin: 0;
  color: var(--button);
  font-size: 1.25rem;
  line-height: 1.2;
}

.settings-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
}

.status-line {
  display: none;
  margin: 0;
  color: #506079;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-line.is-error {
  color: #c32645;
}

.status-line.is-ready {
  color: #23795b;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 32, 51, 0.46);
  backdrop-filter: blur(3px);
}

.auth-card {
  width: min(100%, 360px);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(23, 32, 51, 0.18);
}

.settings-card {
  width: min(100%, 520px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.settings-dialog {
  width: min(100%, 720px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.auth-card h2 {
  margin: 0;
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1.2;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.auth-card form {
  display: grid;
  gap: 10px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.session-choice-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.settings-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.manage-card {
  width: min(100%, 980px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.manage-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.manage-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manage-summary {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.manage-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 8px;
}

.manage-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
}

.manage-row input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}

.manage-row-main {
  min-width: 0;
}

.manage-row-title {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.manage-row-meta,
.manage-row-detail {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manage-row-actions {
  display: flex;
  gap: 6px;
}

.manage-row-actions .action-button {
  min-width: 54px;
}

.report-card {
  width: min(100%, 1060px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.report-summary-item {
  display: grid;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
}

.report-summary-item span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.report-summary-item strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.1;
}

.report-summary-item b {
  color: var(--accent);
  font-size: 0.84rem;
}

.report-table-wrap {
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.report-table th,
.report-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.report-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: var(--button);
  font-size: 0.72rem;
  text-transform: uppercase;
  z-index: 1;
}

.conflict-card,
.audit-card {
  width: min(100%, 1060px);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.conflict-list,
.audit-results {
  display: grid;
  gap: 8px;
}

.conflict-row,
.audit-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  text-align: left;
}

.conflict-row {
  cursor: pointer;
}

.conflict-row.is-selected {
  border-color: var(--accent);
  background: #f8fafc;
}

.conflict-row-title,
.audit-row-title {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.conflict-row-meta,
.audit-row-meta,
.audit-row-detail {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.conflict-detail {
  display: grid;
  gap: 10px;
}

.conflict-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.conflict-panel {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
}

.conflict-panel h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.conflict-panel dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0;
  font-size: 0.76rem;
}

.conflict-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.conflict-panel dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

.conflict-resolution-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.audit-detail {
  max-height: 58vh;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.74rem;
  white-space: pre-wrap;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 0.62fr;
  gap: 10px;
}

.settings-provider-row {
  display: grid;
  gap: 8px;
}

.settings-grid .full-field {
  grid-column: 1 / -1;
}

.business-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.business-settings-grid .full-field {
  grid-column: 1 / -1;
}

.settings-section {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.settings-tool-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.settings-tool-row .action-button {
  width: 100%;
}

.auth-card label {
  font-size: 0.78rem;
}

.auth-card input {
  min-height: 38px;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}

.password-field input {
  min-width: 0;
}

.password-toggle {
  min-width: 54px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  color: var(--button);
  font-weight: 800;
  cursor: pointer;
}

.auth-error {
  min-height: 18px;
  color: #c32645;
  font-size: 0.8rem;
  font-weight: 700;
}

.editor-section {
  display: grid;
  gap: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.section-title {
  margin: 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.field-grid > label:nth-child(1),
.field-grid > label:nth-child(2) {
  grid-column: span 3;
}

.field-grid > label:nth-child(3),
.field-grid > label:nth-child(4) {
  grid-column: span 2;
}

.compact-document-grid {
  grid-template-columns: 1.05fr 0.95fr 0.8fr 1.05fr;
  align-items: end;
}

.compact-document-grid > label:nth-child(1),
.compact-document-grid > label:nth-child(2),
.compact-document-grid > label:nth-child(3),
.compact-document-grid > label:nth-child(4) {
  grid-column: auto;
}

.compact-document-grid label {
  font-size: 0.8rem;
}

label {
  display: grid;
  gap: 4px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
  flex: 0 0 auto;
}

.comments-toggle-label {
  margin-top: 2px;
}

.comments-field {
  margin-top: -2px;
}

.customer-name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  align-items: end;
}

.customer-clear-button {
  min-height: 32px;
  padding-inline: 9px;
}

.customer-suggestions {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  color: var(--accent);
}

.customer-suggestions select {
  border-color: #94a3b8;
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: var(--field);
  color: var(--ink);
  padding: 6px 8px;
}

textarea {
  resize: vertical;
}

#customer-address {
  height: 68px;
}

#comments {
  height: 56px;
}

.line-editor {
  display: grid;
  gap: 6px;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  min-height: 0;
  min-width: 0;
}

.line-card {
  display: grid;
  grid-template-columns: minmax(72px, 0.75fr) minmax(108px, 1fr) minmax(128px, 1.1fr) minmax(100px, 0.8fr);
  gap: 6px;
  align-items: start;
  padding: 7px 0 9px;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  min-width: 0;
}

.line-card .item-field {
  grid-column: 1 / -1;
}

.line-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.line-card label {
  font-size: 0.75rem;
}

.line-card input {
  min-height: 32px;
  min-width: 0;
  padding: 6px 8px;
}

.line-card select {
  min-height: 32px;
  min-width: 0;
  padding: 6px 8px;
  appearance: auto;
}

.line-card .unit-select.is-blank-unit {
  font-size: 0.68rem;
}

.line-card .unit-select .blank-unit-option {
  font-size: 0.72rem;
}

.line-card .line-checkbox-label {
  display: none;
}

.tax-enabled .line-card .line-checkbox-label {
  display: flex;
}

.line-card .line-checkbox-label input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.qty-input {
  text-align: center;
}

.amount-override-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-end;
  grid-column: auto;
  min-width: 0;
}

.amount-override-toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.amount-override-toggle-label input[type="checkbox"] {
  width: 13px;
  min-height: 13px;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.amount-override-input {
  min-height: 34px;
  padding: 7px 8px;
}

.line-rate-delete-field {
  display: grid;
  grid-template-columns: minmax(94px, 1fr) 32px;
  gap: 6px;
  align-items: end;
}

.line-rate-delete-field label {
  min-width: 0;
}

.line-card .line-remove-button {
  width: 32px;
  min-width: 32px;
  height: 34px;
  align-self: end;
}

.lock-button {
  border-color: #9aa7b7;
  background: #ffffff;
  color: var(--button);
}

.is-view-mode .entry-grid input,
.is-view-mode .entry-grid select,
.is-view-mode .entry-grid textarea {
  pointer-events: none;
  background: var(--surface);
  color: var(--muted);
}

.is-view-mode .action-footer,
.is-view-mode #add-line-footer,
.is-view-mode #save-quote {
  display: none;
}

.is-view-mode #edit-current-quote {
  display: block !important;
}

.is-view-mode .line-card .line-remove-button {
  display: none;
}

.money-input {
  text-align: right;
}

.icon-button,
.action-button {
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  width: 28px;
  height: 30px;
  background: #f1f5f9;
  color: var(--accent);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.invoice-actions {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.line-entry-actions {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 8px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding-top: 8px;
  background: var(--panel);
}

.line-entry-actions .action-button {
  width: 100%;
}

#edit-current-quote {
  grid-column: 1 / -1;
}

.action-button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--button-border);
  border-radius: 4px;
  background: var(--button);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.1;
  box-shadow: none;
  cursor: pointer;
}

.action-button.secondary {
  border: 1px solid #9aa7b7;
  background: #ffffff;
  color: var(--button);
  box-shadow: none;
}

.action-button.danger {
  border-color: #f0abc2;
  color: #c32645;
}

.action-button:hover:not(:disabled),
.action-button:focus-visible:not(:disabled) {
  border-color: var(--accent);
  outline: none;
  filter: saturate(1.08);
}

.action-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.record-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: none;
  padding: 10px 16px;
  border-radius: 8px;
  background: #23795b;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.record-toast.is-visible {
  display: block;
}

.record-toast.is-error {
  background: #c32645;
}

.app-context-menu {
  position: fixed;
  z-index: 10002;
  display: grid;
  gap: 2px;
  min-width: 170px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.app-context-menu button {
  min-height: 30px;
  padding: 7px 9px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.app-context-menu button:hover,
.app-context-menu button:focus-visible {
  background: #f1f5f9;
  outline: none;
}

.app-context-menu button:disabled {
  color: #8a99ad;
  cursor: not-allowed;
}

.preview-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  justify-items: stretch;
  align-content: start;
  gap: 10px;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: sticky;
  top: 20px;
  width: 100%;
  max-width: 100%;
}

.preview-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(112px, 100%), 1fr));
  gap: 6px;
  width: 100%;
  max-width: 8.5in;
  min-width: 0;
  justify-self: center;
  padding: 0;
  box-sizing: border-box;
}

.preview-actions .action-button {
  width: 100%;
  min-width: 0;
  white-space: normal;
}

.preview-stage {
  position: relative;
  width: 100%;
  max-width: 8.5in;
  overflow: hidden;
  justify-self: center;
}

.preview-stage .invoice-page {
  transform-origin: top center;
}

.responsive-shell {
  width: min(100%, 1860px);
  margin: 0 auto;
}

.responsive-editor {
  width: 100%;
}

.top-toolbar {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.top-toolbar-card {
  align-content: start;
  padding: 0;
  padding-top: 0;
  border: 0;
  border-top: 0;
  border-radius: 0;
  background: transparent;
}

.entry-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.72fr) minmax(0, 1.28fr);
  gap: 14px;
  min-width: 0;
}

.entry-card {
  align-content: start;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.invoice-detail-card {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  container-type: inline-size;
}

.invoice-detail-card .line-editor {
  max-height: clamp(220px, 38vh, 520px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
}

@container (max-width: 700px) {
  .top-toolbar,
  .entry-grid {
    grid-template-columns: 1fr;
  }
}

@container (max-width: 560px) {
  .line-card {
    grid-template-columns: 1fr 1fr;
  }

  .line-card .item-field,
  .amount-override-wrap {
    grid-column: 1 / -1;
  }

  .line-rate-delete-field {
    grid-template-columns: minmax(0, 1fr) 32px;
  }
}

.entry-card .section-title {
  margin-bottom: 2px;
}

.document-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
  align-items: start;
}

.document-row label {
  font-size: 0.76rem;
}

.document-row input {
  min-height: 32px;
}

.invoice-number-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.date-field {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 5px;
  align-items: end;
  min-width: 0;
}

.date-field label {
  min-width: 0;
}

.compact-button {
  min-height: 32px;
  padding: 5px 9px;
  white-space: nowrap;
}

.invoice-override-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
}

.invoice-override-label input[type="checkbox"] {
  width: 13px;
  min-height: 13px;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

#quote-number[readonly] {
  background: var(--surface);
  color: var(--muted);
  cursor: default;
}

.business-summary {
  display: grid;
  gap: 2px;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.24;
}

.business-summary strong {
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1.2;
}

.business-summary span:empty {
  display: none;
}

.invoice-options-grid {
  display: grid;
  grid-template-columns: minmax(116px, 0.85fr) minmax(136px, 1fr) minmax(92px, 0.7fr) minmax(100px, 0.75fr);
  gap: 6px;
  align-items: end;
}

.invoice-options-grid label {
  min-width: 0;
}

.document-type-field select {
  min-height: 32px;
}

.business-settings-fields {
  display: grid;
  gap: 8px;
}

.tax-toggle-label {
  align-self: end;
  min-height: 32px;
  padding-bottom: 6px;
}

.tax-toggle-label input {
  width: 16px;
  min-height: 16px;
}

.invoice-business-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.invoice-business-grid label {
  font-size: 0.76rem;
}

.invoice-business-grid input {
  min-height: 34px;
}

.invoice-business-grid .business-name-field {
  grid-column: span 3;
}

.invoice-business-grid .business-address-field {
  grid-column: span 4;
}

.invoice-business-grid .business-website-field {
  grid-column: span 3;
}

.invoice-business-grid .business-phone-field {
  grid-column: span 2;
}

.action-footer {
  padding-top: 12px;
}

.footer-actions {
  justify-content: flex-start;
}

.compact-actions {
  margin-top: 4px;
}

.invoice-page {
  width: 8.5in;
  min-height: 11in;
  padding: 0.46in 0.42in 0.34in;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
}

.logo-row {
  display: flex;
  justify-content: center;
}

.logo {
  width: 3.05in;
  max-width: 38%;
  height: auto;
}

.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45in;
  margin-top: 0.1in;
}

.business-block,
.customer-block {
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.42;
}

.business-block {
  line-height: 1.28;
}

.customer-block {
  white-space: pre-line;
}

.business-block .soft {
  color: var(--accent-2);
  font-style: italic;
}

.business-block .business-name,
.business-block .business-tagline,
.business-block .business-address,
.business-block .business-phone-row,
.business-block .business-website {
  display: block;
  margin: 0;
}

.business-block .business-address {
  white-space: pre-line;
}

.title-block {
  display: grid;
  align-content: start;
  justify-items: end;
  color: var(--accent);
}

.document-title {
  margin: 0 0 0.58in;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.meta-line {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  justify-content: end;
  margin: 3px 0;
  font-size: 14px;
  font-weight: 800;
}

.meta-line span:last-child {
  color: #0a4ea8;
}

.customer-block {
  min-height: 0.88in;
  margin-top: 0.16in;
}

.comments {
  margin-top: 0.08in;
  min-height: 0.46in;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  width: 100%;
}

.comments .comment-text {
  display: block;
  width: 100%;
  margin-top: 4px;
  color: var(--ink);
  font-weight: 500;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.invoice-table {
  width: 100%;
  margin-top: 0.2in;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.invoice-table th,
.invoice-table td {
  height: 0.28in;
  border: 2px solid var(--line);
  padding: 5px 8px;
  vertical-align: middle;
}

.invoice-table th {
  background: var(--fill);
  color: var(--accent);
  font-weight: 900;
  text-align: center;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.preview-empty-row td {
  height: 0.28in;
}

.item-col {
  width: 49%;
}

.qty-col {
  width: 14%;
  text-align: center;
}

.unit-col {
  width: 10%;
  text-align: center;
}

.rate-col {
  width: 13%;
}

.amount-col {
  width: 14%;
}

.money-cell {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px;
  align-items: baseline;
  width: 100%;
}

.money-cell .currency {
  text-align: left;
}

.money-cell .number {
  text-align: right;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 3.66in;
  margin-top: 0;
}

.totals-table {
  grid-column: 2;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}

.totals-table td {
  height: 0.33in;
  border: 2px solid var(--line);
  padding: 6px 8px;
}

.totals-table td:first-child {
  width: 62%;
  color: var(--accent-2);
  font-weight: 900;
  text-align: right;
}

.totals-table .due-row td {
  background: #fff2a8;
  color: var(--accent);
  font-size: 16px;
  font-weight: 900;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.footer {
  margin-top: auto;
  padding-top: 0.34in;
  display: grid;
  gap: 0.13in;
  text-align: center;
}

.footer strong {
  color: var(--accent);
  font-size: 18px;
}

.footer span {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.footer b {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .shell-resizer {
    display: none;
  }

  .editor {
    position: static;
  }

  .preview-wrap {
    position: static;
  }
}

@media (max-width: 1180px) {
  .entry-grid {
    grid-template-columns: 1fr;
  }

  .top-toolbar {
    grid-template-columns: 1fr;
  }

  .document-row {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

.save-hint {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #23795b;
  color: white;
  padding: 14px 22px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  text-align: center;
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: 100%;
    min-width: 0;
    padding: 8px;
    gap: 12px;
  }

  .editor {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  .top-toolbar-card label {
    font-size: 0.74rem;
  }

  #invoice-search,
  #quote-list {
    min-height: 32px;
    padding: 6px 7px;
    font-size: 0.74rem;
  }

  #quote-list {
    text-overflow: ellipsis;
  }

  .invoice-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .invoice-actions .action-button {
    padding: 5px 4px;
    font-size: 0.7rem;
  }

  .manage-toolbar {
    grid-template-columns: 1fr;
  }

  .manage-bulk-actions {
    justify-content: stretch;
  }

  .manage-bulk-actions .action-button {
    flex: 1 1 auto;
  }

  .manage-results {
    grid-template-columns: 1fr;
  }

  .manage-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .manage-row-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .report-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .conflict-panels,
  .invoice-options-grid {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    margin-inline: calc(50% - 50vw + 8px);
    justify-content: stretch;
    justify-items: stretch;
    overflow: hidden;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    padding: 0;
  }

  .preview-actions .action-button {
    width: 100%;
    min-height: 28px;
    padding: 5px 8px;
    font-size: 0.76rem;
  }

  .preview-stage {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    justify-self: stretch;
  }

  .top-toolbar-card,
  .entry-card {
    padding: 0;
  }

  .line-card {
    grid-template-columns: 1fr 1fr;
  }

  .invoice-detail-row {
    grid-template-columns: 1fr;
  }

  .line-card .item-field {
    grid-column: 1 / -1;
  }

  .line-rate-delete-field {
    grid-column: auto;
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .line-card .settings-button,
  .settings-button {
    width: 32px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .business-settings-grid {
    grid-template-columns: 1fr;
  }

  .invoice-page {
    min-width: 0;
  }
}

@media print {
  @page {
    size: letter;
    margin: 0 0 0.25in 0;
  }

  body {
    background: white;
  }

  .editor {
    display: none;
  }

  .preview-actions {
    display: none !important;
  }

  .save-hint,
  .record-toast,
  .auth-overlay {
    display: none !important;
  }

  .app-shell {
    display: block;
    min-height: auto;
    padding: 0;
    max-width: none !important;
    margin: 0 !important;
  }

  .preview-wrap {
    display: block;
    overflow: visible;
    position: static;
  }

  .preview-stage {
    position: static;
    overflow: visible !important;
    width: auto;
    max-width: none;
    height: auto !important;
  }

  .invoice-page {
    position: static !important;
    top: auto !important;
    left: auto !important;
    width: 8.5in;
    height: 10.75in;
    min-height: 10.75in;
    padding-bottom: 0;
    box-shadow: none;
    page-break-after: avoid;
    transform-origin: top left !important;
    transform: none !important;
  }

  .footer {
    margin-top: auto;
    padding-top: 0.14in;
    gap: 0.08in;
  }
}

/* Products & Services manager */
.product-manager-card,
.payment-manager-card {
  max-width: 760px;
}
.balance-row td {
  font-weight: 700;
}
.first-run-hint {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.9em;
  line-height: 1.4;
}
.product-table td.product-actions {
  white-space: nowrap;
}
.product-table tr.is-inactive td {
  color: var(--muted);
}
.link-button {
  background: none;
  border: none;
  padding: 0 0.35em;
  margin: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.link-button:hover {
  opacity: 0.8;
}
.link-button.danger {
  color: #b42318;
}
