/* Live invoice entry — edit directly on the A4 sheet */
body.invoice-live-entry {
  --inv-topbar-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --inv-workbench-bg: #eef2f7;
  --inv-card-bg: #ffffff;
  --inv-card-border: #e2e8f0;
  --inv-card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
  --inv-accent: #e31e24;
  --inv-accent-soft: rgba(227, 30, 36, 0.1);
  --inv-indigo: #4f46e5;
  --inv-indigo-soft: #eef2ff;
  background: var(--inv-workbench-bg);
}

body.invoice-live-entry input:focus,
body.invoice-live-entry textarea:focus,
body.invoice-live-entry select:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.invoice-live-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  grid-template-columns: none;
}

.invoice-live-layout .editor {
  display: none;
}

/* —— Sticky toolbar shell —— */
.live-toolbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--inv-workbench-bg);
  border-bottom: none;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  overflow: visible;
}

/* —— Dark top bar —— */
.inv-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 12px 20px;
  background: var(--inv-topbar-bg);
  color: #f8fafc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.inv-topbar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.inv-topbar__logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--inv-accent) 0%, #b9151a 100%);
  color: #fff;
  font-size: 1.1rem;
  box-shadow: 0 6px 18px rgba(227, 30, 36, 0.35);
  flex-shrink: 0;
}

.inv-topbar__brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.inv-topbar__title {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.inv-topbar__sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(248, 250, 252, 0.62);
}

.inv-topbar__nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.inv-topbar__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(248, 250, 252, 0.82);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease, color 0.15s ease;
}

.inv-topbar__back:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.inv-topbar__tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
}

.inv-topbar__tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: rgba(248, 250, 252, 0.72);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.inv-topbar__tab i {
  font-size: 0.85rem;
  opacity: 0.88;
}

.inv-topbar__tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.inv-topbar__tab--active {
  color: #0f172a;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.inv-topbar__tab--active i {
  color: var(--inv-accent);
  opacity: 1;
}

.inv-topbar__status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.inv-edit-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.inv-edit-badge.hidden {
  display: none;
}

.inv-db-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.inv-db-status i {
  font-size: 0.8rem;
  opacity: 0.9;
}

.inv-db-status--checking {
  color: #1e40af;
  background: rgba(219, 234, 254, 0.95);
  border-color: #bfdbfe;
}

.inv-db-status--ok {
  color: #166534;
  background: rgba(220, 252, 231, 0.95);
  border-color: #86efac;
}

.inv-db-status--error {
  color: #991b1b;
  background: rgba(254, 226, 226, 0.95);
  border-color: #fca5a5;
}

.inv-topbar__action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.inv-topbar__action:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

.inv-workbench-toggle__icon {
  transition: transform 0.2s ease;
}

body.invoice-live-entry.inv-workbench-collapsed .inv-workbench-toggle__icon {
  transform: rotate(180deg);
}

body.invoice-live-entry.inv-workbench-collapsed .inv-workbench {
  grid-template-columns: 1fr;
  grid-template-rows: auto;
  padding: 8px 20px 10px;
  gap: 0;
}

body.invoice-live-entry.inv-workbench-collapsed .inv-workbench__panel {
  display: none;
}

body.invoice-live-entry.inv-workbench-collapsed .inv-workbench__actions {
  grid-column: 1;
  grid-row: 1;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  border-left: none;
  align-self: auto;
}

body.invoice-live-entry.inv-workbench-collapsed .inv-workbench__actions .inv-action {
  min-width: 0;
  flex: 0 1 auto;
}

body.invoice-live-entry.inv-workbench-collapsed .preview-wrap--wide {
  padding-top: 16px;
}

/* —— Workbench —— */
.inv-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 10px 16px;
  padding: 14px 20px 12px;
  background: var(--inv-workbench-bg);
  border-bottom: 1px solid #dde3ec;
  overflow: visible;
}

.inv-workbench__tools {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
  overflow: visible;
}

.inv-workbench__panel {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.inv-workbench__actions {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding: 4px 0 4px 16px;
  border-left: 1px solid #d5dde8;
  align-self: stretch;
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

.inv-workbench__tip {
  grid-column: auto;
  grid-row: auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #64748b;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.inv-workbench__tip i {
  color: var(--inv-indigo);
  margin-top: 2px;
  flex-shrink: 0;
}

/* —— Tool cards —— */
.inv-tool-card {
  display: flex;
  flex-direction: column;
  min-width: 148px;
  background: var(--inv-card-bg);
  border: 1px solid var(--inv-card-border);
  border-radius: 12px;
  box-shadow: var(--inv-card-shadow);
  overflow: hidden;
}

.inv-tool-card--load {
  min-width: 168px;
}

.inv-tool-card--customer {
  min-width: 190px;
  flex: 1 1 190px;
  max-width: 240px;
}

.inv-tool-card--package {
  min-width: 240px;
  flex: 1.4 1 260px;
  max-width: 320px;
  overflow: visible;
  position: relative;
  z-index: 1;
}

.inv-tool-card--package:focus-within {
  z-index: 280;
}

.inv-tool-card--mode,
.inv-tool-card--layout {
  min-width: 148px;
}

.inv-tool-card__head {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #64748b;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #eef2f7;
}

.inv-tool-card__head i {
  color: var(--inv-indigo);
  font-size: 0.78rem;
}

.inv-tool-card__link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--inv-indigo);
  background: var(--inv-indigo-soft);
  border: 1px solid #c7d2fe;
  transition: background 0.15s ease;
}

.inv-tool-card__link:hover {
  background: #e0e7ff;
}

.inv-tool-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
}

.inv-tool-card__body--row {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
}

.inv-tool-card__options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inv-tool-card__hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.4;
  color: #94a3b8;
}

.inv-tool-card__hint-link {
  color: var(--inv-indigo);
  font-weight: 600;
  text-decoration: none;
}

.inv-tool-card__hint-link:hover {
  text-decoration: underline;
}

.toolbar-load-invoice {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.toolbar-load-invoice .toolbar-control {
  flex: 1;
  min-width: 0;
}

/* —— Controls —— */
.toolbar-control,
.live-toolbar select.toolbar-control {
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  padding: 0 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink, #0f172a);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.toolbar-control:hover {
  border-color: #94a3b8;
}

.toolbar-control:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.inv-chip-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 6px 10px;
  min-height: 34px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.inv-chip-toggle:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.inv-chip-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--inv-indigo);
}

.inv-chip-toggle:has(input:checked) {
  color: #4338ca;
  background: var(--inv-indigo-soft);
  border-color: #c7d2fe;
}

.inv-layout-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  white-space: nowrap;
}

/* —— Segment control (entry mode) —— */
.inv-segment {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  width: 100%;
}

.inv-segment__btn,
.live-toolbar .work-mode-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  margin: 0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.inv-segment__btn:hover,
.live-toolbar .work-mode-tab:hover {
  color: #0f172a;
  background: rgba(255, 255, 255, 0.72);
}

.inv-segment__btn.active,
.live-toolbar .work-mode-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--inv-accent) 0%, #c41a1f 100%);
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.28);
}

/* —— Action buttons —— */
.inv-action,
.inv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.inv-action:active,
.inv-btn:active {
  transform: translateY(1px);
}

.inv-action--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--inv-accent) 0%, #c41a1f 100%);
  box-shadow: 0 4px 14px rgba(227, 30, 36, 0.32);
}

.inv-action--primary:hover {
  box-shadow: 0 6px 20px rgba(227, 30, 36, 0.4);
}

.inv-action--whatsapp {
  color: #fff;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.28);
}

.inv-action--whatsapp:hover {
  box-shadow: 0 6px 18px rgba(37, 211, 102, 0.38);
}

.inv-action--ghost,
.inv-btn--soft {
  color: #334155;
  background: #fff;
  border-color: #cbd5e1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.inv-action--ghost:hover,
.inv-btn--soft:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.inv-btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--inv-accent, #e31e24) 0%, #c41a1f 100%);
  box-shadow: 0 4px 14px rgba(227, 30, 36, 0.28);
}

.inv-btn--primary:hover {
  box-shadow: 0 6px 18px rgba(227, 30, 36, 0.38);
}

.inv-workbench__actions .inv-action {
  min-width: 132px;
}

/* Package combobox in toolbar */
.inv-tool-card--package .package-combobox {
  width: 100%;
  position: relative;
  z-index: 2;
}

.inv-tool-card--package .inv-tool-card__body {
  overflow: visible;
}

.invoice-live-entry .package-combobox__input,
.live-toolbar .package-combobox__input {
  max-width: none;
  cursor: text;
}

.invoice-live-entry .package-combobox__native,
.live-toolbar .package-combobox__native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
  margin: -1px;
}

.invoice-live-entry .package-combobox__list,
.live-toolbar .package-combobox__list {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 2px;
  z-index: 300;
  margin-bottom: 0;
  padding: 0.35rem 0;
  list-style: none;
  max-height: 14rem;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}

.invoice-live-entry .package-combobox__option,
.live-toolbar .package-combobox__option {
  padding: 0.5rem 0.85rem;
  font-size: 0.8125rem;
  color: var(--ink, #0f172a);
  cursor: pointer;
  line-height: 1.35;
}

.invoice-live-entry .package-combobox__option:hover,
.invoice-live-entry .package-combobox__option--active,
.live-toolbar .package-combobox__option:hover,
.live-toolbar .package-combobox__option--active {
  background: var(--inv-indigo-soft);
  color: #3730a3;
}

/* Legacy class aliases (drawer / old markup) */
.live-toolbar__row,
.live-toolbar__fields,
.live-toolbar__actions,
.toolbar-field,
.toolbar-tip,
.toolbar-toggle,
.toolbar-pill,
.edit-mode-badge,
.package-setup-link {
  /* kept for search page compatibility if shared */
}

.preview-wrap--wide {
  flex: 1;
  width: 100%;
  max-width: none;
  padding: 24px 32px 48px;
  align-items: center;
  background: linear-gradient(180deg, #e8ebf0 0%, #dfe3ea 100%);
}

.live-canvas {
  width: 100%;
  max-width: min(1200px, 96vw);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-wrap--wide .preview-label {
  align-self: flex-start;
  margin-left: calc((100% - 210mm) / 2);
  max-width: 210mm;
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 6px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
}

.preview-wrap--wide .preview-label::before {
  content: "\f05a";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--inv-indigo, #4f46e5);
  font-size: 0.85rem;
  letter-spacing: 0;
  text-transform: none;
}

.invoice-live-sheet {
  width: 210mm;
  max-width: 100%;
  min-width: 0;
  box-shadow: 0 12px 40px rgba(15, 20, 25, 0.12), 0 0 0 1px rgba(15, 20, 25, 0.04);
}

/* Inline fields on the invoice */
.inv-live-input,
.inv-live-select,
.inv-live-textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: #0a0a0a;
  -webkit-text-fill-color: currentColor;
  background: #fff;
  border: 1px solid #e2e5eb;
  border-radius: 4px;
  padding: 3px 8px;
  margin: 0;
  line-height: 1.4;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.inv-live-input:hover,
.inv-live-select:hover,
.inv-live-textarea:hover {
  background: #fff;
  border-color: #c8cdd6;
}

.inv-live-input:focus,
.inv-live-select:focus,
.inv-live-textarea:focus {
  outline: none;
  background: #fff;
  border-color: #9aa3ad;
  box-shadow: 0 0 0 2px rgba(15, 20, 25, 0.06);
}

.inv-live-customer {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1em;
}

.inv-live-date {
  width: auto;
  min-width: 130px;
  display: inline-block;
  vertical-align: baseline;
}

.inv-live-money {
  width: 88px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.inv-live-qty {
  text-align: center;
  padding: 2px 4px;
}

.inv-live-price {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.invoice-live-entry .inv-info-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
}

.invoice-live-entry .inv-info-row strong {
  flex-shrink: 0;
}

.invoice-live-entry .inv-info-row .inv-live-input,
.invoice-live-entry .inv-info-row .inv-live-select {
  flex: 1;
  min-width: 120px;
}

.invoice-live-entry .inv-date-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.invoice-live-entry .items-table .inv-live-input.desc-input {
  width: 100%;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Live line-items table — keep real table layout (full width, columns under headers) */
.invoice-live-entry .table-container {
  width: 100%;
}

.invoice-live-entry .inv-add-line-wrap {
  margin: 8px 0 0;
  padding: 0 4px;
}

.invoice-live-entry .items-table--live {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.invoice-live-entry .items-table--live col.col-no { width: 36px; }
.invoice-live-entry .items-table--live col.col-qty { width: 52px; }
.invoice-live-entry .items-table--live col.col-price { width: 80px; }
.invoice-live-entry .items-table--live col.col-total { width: 92px; }

.invoice-live-entry .items-table--fee col.col-no { width: 32px; }
.invoice-live-entry .items-table--fee col.col-desc { width: auto; }
.invoice-live-entry .items-table--fee col.col-gov,
.invoice-live-entry .items-table--fee col.col-svc,
.invoice-live-entry .items-table--fee col.col-total-charge { width: 78px; }

.invoice-live-entry .items-table--fee {
  table-layout: fixed;
}

.invoice-live-entry .items-table--fee .col-gov,
.invoice-live-entry .items-table--fee .col-total-charge,
.invoice-live-entry .items-table--fee .col-svc {
  width: 78px;
  max-width: 78px;
  text-align: right;
  white-space: normal;
  box-sizing: border-box;
  padding-left: 4px;
  padding-right: 4px;
  vertical-align: middle;
  line-height: 1.15;
  font-size: 0.68rem;
}

.invoice-live-entry .items-table--fee td.col-gov,
.invoice-live-entry .items-table--fee td.col-total-charge,
.invoice-live-entry .items-table--fee td.col-svc {
  font-size: 0.82rem;
  white-space: nowrap;
}

.invoice-live-entry .items-table--fee .inv-live-gov,
.invoice-live-entry .items-table--fee .inv-live-total-charge {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: right;
  padding-left: 2px;
  padding-right: 2px;
}

.invoice-live-entry .items-table--fee .inv-fee-svc-display {
  display: block;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--inv-muted, #64748b);
  padding: 4px 2px;
}

.invoice-live-entry .inv-fee-service-field {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 4px;
}

.invoice-live-entry .inv-fee-service-field .desc-input {
  flex: 1 1 auto;
  min-width: 0;
}

.invoice-live-entry .inv-remove-line {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 1px solid #fecaca;
  border-radius: 50%;
  padding: 0;
  background: #fff;
  color: #dc2626;
  font-size: 1rem;
  line-height: 18px;
  cursor: pointer;
}

.invoice-live-entry .inv-remove-line:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.invoice-live-entry .items-table--live tr.inv-export-hide,
.invoice-live-entry .inv-export-hide,
.invoice.pro-invoice.pdf-export .inv-export-hide,
.invoice.pro-invoice.pdf-export .inv-remove-line,
.invoice.pro-invoice.pdf-export .inv-add-line-wrap,
.pdf-capture-host .inv-export-hide,
.pdf-capture-host .inv-remove-line,
.pdf-capture-host .inv-add-line-wrap {
  display: none !important;
}

.invoice-live-entry .items-table--live thead {
  display: table-header-group;
}

.invoice-live-entry .items-table--live tbody {
  display: table-row-group;
}

.invoice-live-entry .items-table--live tr {
  display: table-row !important;
}

.invoice-live-entry .items-table--live th,
.invoice-live-entry .items-table--live td {
  display: table-cell !important;
  vertical-align: middle;
}

.invoice-live-entry .items-table--live tr.inv-live-row {
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  gap: 0;
}

.invoice-live-entry .items-table--live tr.inv-live-row td {
  padding: 5px 8px;
}

.invoice-live-entry .items-table--live .col-no {
  width: 36px;
  text-align: center;
  font-weight: 600;
  color: var(--ink-light, #8b949e);
}

.invoice-live-entry .items-table--live .col-desc {
  width: auto;
  text-align: left;
}

.invoice-live-entry .items-table--live .col-qty {
  width: 52px;
  text-align: center;
}

.invoice-live-entry .items-table--live .col-price {
  width: 80px;
  text-align: right;
}

.invoice-live-entry .items-table--live .col-total {
  width: 92px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 10px;
}

.invoice-live-entry .items-table--live input.inv-live-input {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 4px 4px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: #0a0a0a;
  -webkit-text-fill-color: currentColor;
  opacity: 1;
  box-sizing: border-box;
  border: none;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
}

.invoice-live-entry .items-table--live input.inv-live-input:hover {
  background: #f6f7f9;
  border: none;
  box-shadow: none;
}

.invoice-live-entry .items-table--live input.inv-live-input:focus {
  background: #f3f4f6;
  border: none;
  outline: 1px solid #c8cdd6;
  box-shadow: none;
}

.invoice-live-entry .items-table--live input.inv-live-qty,
.invoice-live-entry .items-table--live input.inv-live-price {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.invoice-live-entry .items-table--live input.inv-live-input::placeholder {
  color: #8b949e;
  font-weight: 500;
  opacity: 1;
}

.invoice-live-entry .items-table--live tr.inv-live-row:focus-within {
  background: #f8f9fb;
}

/* QR code — red border with inner gap, sharp scan */
.invoice-live-entry .qr-box {
  width: 116px;
  height: 116px;
  min-width: 116px;
  min-height: 116px;
  padding: 7px;
  border: 2px solid var(--brand, #e31e24) !important;
  border-radius: 6px;
  background: #fff;
  box-sizing: border-box;
}

.invoice-live-entry .qr-box canvas,
.invoice-live-entry .qr-box img {
  width: 96px !important;
  height: 96px !important;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.invoice-live-entry .inv-customer-row .inv-live-customer {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.invoice-live-entry .verify-qr-column {
  align-items: stretch;
}

.invoice-live-entry .inv-bank-block--with-qr {
  margin-top: 0;
}

.invoice-live-entry .stamp-seal {
  width: 150px;
  height: 150px;
}

.invoice-live-entry .verify-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0a0a0a;
  line-height: 1.3;
}

.invoice-live-entry .verify-sub {
  font-size: 0.7rem;
  color: #5c6570;
  line-height: 1.35;
}

.invoice-live-entry .totals-table .inv-live-money {
  margin-left: auto;
}

.invoice-live-entry .summary-note .inv-live-textarea {
  width: 100%;
  min-height: 48px;
  resize: vertical;
  font-size: 0.85em;
  line-height: 1.4;
}

.invoice-live-entry #paymentTermsCustomWrap {
  margin-top: 4px;
}

.invoice-live-entry #paymentTermsCustomWrap.hidden {
  display: none !important;
}

/* Catalog drawer */
.catalog-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100vh;
  z-index: 300;
  background: #fff;
  border-left: 1px solid var(--border, #e2e5eb);
  box-shadow: -8px 0 32px rgba(15, 20, 25, 0.12);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 16px 18px 24px;
}

.catalog-drawer.is-open {
  transform: translateX(0);
}

.catalog-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #e2e5eb);
  background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  margin: -16px -18px 14px;
  padding: 16px 18px 12px;
}

.catalog-drawer__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.catalog-drawer__head h2::before {
  content: "\f02c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  color: var(--inv-indigo, #4f46e5);
  font-size: 0.9rem;
}

.catalog-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 299;
  background: rgba(15, 20, 25, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.catalog-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.live-toolbar .db-status {
  margin: 0;
  padding: 6px 10px;
  font-size: 0.72rem;
  border-radius: 8px;
  white-space: nowrap;
}

input[type="number"]#invoiceNumber {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .inv-workbench {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .inv-workbench__panel {
    grid-column: 1;
    grid-row: 1;
  }

  .inv-workbench__actions {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    border-left: none;
    border-top: 1px solid #d5dde8;
    padding-top: 10px;
  }

  .inv-workbench__tip {
    /* stays inside panel */
  }

  body.invoice-live-entry.inv-workbench-collapsed .inv-workbench {
    grid-template-rows: auto;
  }

  body.invoice-live-entry.inv-workbench-collapsed .inv-workbench__actions {
    grid-row: 1;
  }

  .inv-workbench__actions .inv-action {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
  }
}

@media (max-width: 900px) {
  .preview-wrap--wide {
    padding: 16px 12px 32px;
  }

  .preview-wrap--wide .preview-label {
    margin-left: 0;
    text-align: center;
  }

  .invoice-live-sheet.fit-a4 {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .inv-topbar {
    padding-inline: 14px;
  }

  .inv-topbar__status {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .inv-workbench {
    padding-inline: 12px;
  }

  .inv-tool-card--customer,
  .inv-tool-card--package {
    max-width: none;
    flex: 1 1 100%;
  }

  .live-toolbar__row {
    padding-inline: 12px;
  }

  .live-toolbar__row--tools {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .live-toolbar__fields {
    grid-column: 1;
    grid-row: auto;
  }

  .toolbar-tip {
    grid-column: 1;
    grid-row: auto;
  }

  .live-toolbar__actions {
    grid-column: 1;
    grid-row: auto;
    padding-left: 0;
    padding-top: 8px;
    border-left: none;
    border-top: 1px solid #e2e5eb;
    flex-wrap: wrap;
    align-self: auto;
  }

  .toolbar-field--customer .toolbar-control,
  .toolbar-field--package .package-combobox {
    width: 100%;
    min-width: 0;
  }
}

@media print {
  .live-toolbar,
  .catalog-drawer,
  .catalog-drawer-backdrop,
  .preview-label,
  .no-print {
    display: none !important;
  }

  .preview-wrap--wide {
    padding: 0;
    background: #fff;
  }

  .inv-live-input,
  .inv-live-select,
  .inv-live-textarea {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }
}
