/* invoice.Now — Custom Styles (Live Document Edition) */

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.no-scroll {
  overflow: hidden;
}

/* ── Toast ── */
.toast-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#toast[data-tone="error"] {
  background: #7f1d1d;
  color: #fff7ed;
}

#toast[data-tone="error"] svg {
  color: #fecaca;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

/* ── Hide number spinners ── */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* ── Live Header ── */
.live-header {
  height: 56px;
  flex-shrink: 0;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 20;
  position: sticky;
  top: 0;
}

.live-header-left {
  display: flex;
  align-items: center;
}

.live-header-center {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Currency & Template Selectors ── */
.currency-select {
  font-size: 0.75rem;
  font-weight: 600;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.currency-select:focus { border-color: #111827; }

.currency-select-mobile {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8rem;
}

/* ── Live Document Layout ── */
.live-doc-layout {
  display: flex;
  min-height: 100%;
  position: relative;
}

.live-doc-surface {
  flex: 1;
  padding: 40px 24px 80px;
  display: flex;
  justify-content: center;
  min-height: 100%;
}

/* ── Guide Sidebar ── */
.guide-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  height: calc(100vh - 56px);
  overflow-y: auto;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  z-index: 10;
}

.guide-sidebar.is-collapsed {
  margin-left: -240px;
  opacity: 0;
  pointer-events: none;
}

.guide-sidebar-inner {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.guide-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #9ca3af;
}

.guide-collapse-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #9ca3af;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.guide-collapse-btn:hover {
  color: #374151;
  background: #f3f4f6;
}

/* Expand button (visible when sidebar collapsed) */
.guide-expand-btn {
  position: sticky;
  top: 16px;
  left: 0;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin: 16px 0 0 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #9ca3af;
  border-radius: 8px;
  cursor: pointer;
  z-index: 10;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.guide-expand-btn:hover {
  color: #374151;
  border-color: #d1d5db;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.guide-expand-btn.hidden {
  display: none;
}

/* First-visit nudge */
.guide-nudge {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #0c4a6e;
}

.guide-nudge.hidden {
  display: none;
}

.guide-nudge-icon {
  flex-shrink: 0;
  color: #0284c7;
  margin-top: 1px;
}

.guide-nudge-dismiss {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #7dd3fc;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  margin-left: auto;
}

.guide-nudge-dismiss:hover {
  color: #0284c7;
}

/* Section buttons */
.guide-sections {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.guide-section {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
  width: 100%;
}

.guide-section:hover {
  background: #f9fafb;
}

.guide-section-status {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.guide-section-status.is-done {
  border-color: #22c55e;
  background: #22c55e;
}

.guide-section-status.is-done::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.guide-section-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.guide-section-label {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  line-height: 1.3;
}

.guide-section-hint {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.3;
}

.guide-section-hint.is-filled {
  color: #22c55e;
}

/* Progress bar */
.guide-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.guide-progress-bar {
  height: 4px;
  background: #f3f4f6;
  border-radius: 2px;
  overflow: hidden;
}

.guide-progress-fill {
  height: 100%;
  background: #22c55e;
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-progress-text {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 600;
}

#pdf-preview {
  width: 794px;
  min-height: 1123px;
  background: white;
  flex-shrink: 0;
  box-sizing: border-box;
  transform-origin: top center;
}

.shadow-paper {
  box-shadow:
    0 1px 3px rgba(0,0,0,0.04),
    0 8px 24px rgba(0,0,0,0.08),
    0 24px 48px rgba(0,0,0,0.04);
  border-radius: 2px;
}

#preview-wrapper {
  --preview-scale: 1;
  --preview-height: 1123px;
  transform-origin: top center;
  transform: scale(var(--preview-scale));
  margin-bottom: calc(var(--preview-height) * -1 * (1 - var(--preview-scale)));
  will-change: transform;
}

/* ── Live Document Editing ── */

/* Hover state for editable fields */
[data-field].live-hover,
[data-item-index].live-hover {
  outline: 2px solid rgba(59, 130, 246, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
  cursor: pointer;
  background: rgba(59, 130, 246, 0.03);
}

.tpl-midnight [data-field].live-hover,
.tpl-midnight [data-item-index].live-hover {
  outline-color: rgba(96, 165, 250, 0.4);
  background: rgba(96, 165, 250, 0.06);
}

/* Empty state placeholders */
[data-field].is-empty {
  color: rgba(0, 0, 0, 0.25) !important;
  font-style: italic;
  cursor: pointer;
  min-height: 1.2em;
}

.tpl-midnight [data-field].is-empty {
  color: rgba(255, 255, 255, 0.25) !important;
}

/* Logo empty state */
img[data-field="logo"].is-empty {
  display: block !important;
  width: 120px;
  height: 40px;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,0.04) 4px,
    rgba(0,0,0,0.04) 8px
  );
  border: 1px dashed rgba(0,0,0,0.15);
  border-radius: 4px;
  cursor: pointer;
  object-fit: none;
}

.tpl-midnight img[data-field="logo"].is-empty {
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(255,255,255,0.06) 4px,
    rgba(255,255,255,0.06) 8px
  );
  border-color: rgba(255,255,255,0.15);
}

/* Active editing state */
[data-field].is-editing {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-radius: 2px;
  background: rgba(59, 130, 246, 0.04);
}

.tpl-midnight [data-field].is-editing {
  background: rgba(59, 130, 246, 0.08);
}

/* Inline field editors */
.live-field-editor {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  line-height: inherit;
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.live-field-editor::placeholder {
  color: rgba(0, 0, 0, 0.25);
  font-style: italic;
}

.tpl-midnight .live-field-editor {
  color: #fff;
}

.tpl-midnight .live-field-editor::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.live-field-textarea {
  resize: none;
  white-space: pre-wrap;
  overflow: hidden;
  min-height: 2em;
}

.live-field-date {
  cursor: pointer;
  text-align: inherit;
}

.live-field-number {
  width: 3em;
  text-align: center;
}

.live-field-editor-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.live-field-suffix {
  opacity: 0.5;
  font-size: 0.85em;
}

/* ── In-Document Item Editing ── */
[data-item-index] {
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
}

[data-item-index].is-editing {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-radius: 2px;
  background: rgba(59, 130, 246, 0.04);
  cursor: default;
}

.tpl-midnight [data-item-index].is-editing {
  background: rgba(59, 130, 246, 0.08);
}

.live-item-editor {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.live-item-editor::placeholder {
  color: rgba(0, 0, 0, 0.25);
  font-style: italic;
}

.tpl-midnight .live-item-editor {
  color: #fff;
}

.live-item-delete {
  position: absolute;
  right: -28px;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #9ca3af;
  transition: all 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.live-item-delete:hover {
  color: #ef4444;
  border-color: #fecaca;
}

/* Add item button in document */
.live-add-item-row {
  padding: 6px 0;
}

.live-add-item-btn {
  display: block;
  width: 100%;
  padding: 8px 0;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.25);
  background: transparent;
  border: 1px dashed rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.live-add-item-btn:hover {
  color: rgba(0, 0, 0, 0.5);
  border-color: rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.02);
}

.tpl-midnight .live-add-item-btn {
  color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

.tpl-midnight .live-add-item-btn:hover {
  color: rgba(255, 255, 255, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
}

.live-items-empty {
  padding: 16px 0;
  text-align: center;
  cursor: pointer;
}

.live-items-empty .is-empty {
  color: rgba(0, 0, 0, 0.25);
  font-style: italic;
  font-size: 13px;
}

/* ── Floating Total ── */
.floating-total {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 30;
  transition: opacity 0.2s, transform 0.2s;
}

.floating-total.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.floating-total-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
}

.floating-total-amount {
  font-size: 1.1rem;
}

/* ── Mobile Action Bar ── */
.mobile-action-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 40;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  flex-direction: column;
}

.mobile-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}

.mobile-progress-label {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
}

.mobile-settings-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  color: #6b7280;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.mobile-settings-btn:active {
  background: #e5e7eb;
  color: #111827;
}

.mobile-settings-panel {
  padding: 0 12px 10px;
  display: flex;
  gap: 8px;
}

.mobile-settings-panel.hidden {
  display: none;
}

.mobile-settings-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mobile-settings-label {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  padding-left: 2px;
}

.btn-download-mobile {
  background: #0f172a;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-download-mobile:active { opacity: 0.85; }

/* ── Mobile Field Sheet (Bottom Sheet) ── */
.mobile-field-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.mobile-field-sheet.hidden {
  display: none;
}

.mobile-field-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.mobile-field-sheet.is-open .mobile-field-sheet-backdrop {
  opacity: 1;
}

.mobile-field-sheet-content {
  position: relative;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.mobile-field-sheet.is-open .mobile-field-sheet-content {
  transform: translateY(0);
}

.mobile-field-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f1f5f9;
}

.mobile-field-sheet-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
}

.mobile-field-sheet-actions {
  display: flex;
  gap: 8px;
}

.mobile-field-sheet-btn {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  background: #f1f5f9;
  color: #475569;
  transition: background 0.15s;
}

.mobile-field-sheet-btn:active { background: #e2e8f0; }

.mobile-field-sheet-btn-primary {
  background: #0f172a;
  color: #fff;
}

.mobile-field-sheet-btn-primary:active { opacity: 0.85; }

.mobile-field-sheet-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
}

.mobile-field-input {
  width: 100%;
  font-size: 1rem;
  font-weight: 500;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  background: #f8fafc;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.mobile-field-input:focus {
  border-color: #0f172a;
  box-shadow: 0 0 0 1px #0f172a;
}

textarea.mobile-field-input {
  resize: vertical;
  min-height: 100px;
}

/* ── Dialog ── */
.dialog-modal {
  position: fixed;
  top: 5rem;
  right: 1.25rem;
  z-index: 110;
  width: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}

.dialog-card {
  width: 100%;
  border-radius: 1.25rem;
  background: #ffffff;
  padding: 1.4rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
}

.dialog-modal[data-tone="warning"] .dialog-card {
  border: 1px solid #fed7aa;
  box-shadow: 0 24px 60px rgba(180, 83, 9, 0.12);
}

.dialog-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-close {
  flex-shrink: 0;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  color: #0f172a;
  border-color: #cbd5e1;
  background: #f8fafc;
  outline: none;
}

.dialog-eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.dialog-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.dialog-body {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #475569;
}

.dialog-list {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  color: #475569;
  display: grid;
  gap: 0.45rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.dialog-button {
  border-radius: 0.85rem;
  padding: 0.8rem 1rem;
  font-size: 0.92rem;
  font-weight: 650;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.dialog-button-secondary {
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
}

.dialog-button-primary {
  background: #0f172a;
  color: #fff;
  border: 1px solid #0f172a;
}

.dialog-button-primary:hover,
.dialog-button-primary:focus-visible,
.dialog-button-secondary:hover,
.dialog-button-secondary:focus-visible {
  outline: none;
  filter: brightness(0.98);
}

/* ── Loading State ── */
.btn-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* ── Template System ── */
.template-shell {
  width: 100%;
  min-height: 1123px;
  box-sizing: border-box;
  padding: 56px;
  padding-bottom: 84px;
  background: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
  gap: 22px;
}

.template-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: #000;
}

.template-accent-thick {
  height: 14px;
}

.template-head {
  display: flex;
  gap: 20px;
}

.template-head-split {
  justify-content: space-between;
  align-items: flex-start;
}

.template-head-modern {
  justify-content: space-between;
  align-items: center;
}

.template-head-left,
.template-head-right {
  width: 48%;
}

.template-head-right {
  text-align: right;
}

.template-logo {
  max-height: 62px;
  max-width: 210px;
  object-fit: contain;
  margin-bottom: 12px;
}

.template-title {
  margin: 0 0 14px;
  font-size: 46px;
  line-height: 1;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.template-from-name {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.template-to-name {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.template-subline {
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.template-pre {
  white-space: pre-wrap;
}

.template-meta-row {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  font-size: 11px;
  margin-bottom: 4px;
  text-transform: uppercase;
  font-weight: 700;
}

.template-meta-row span:last-child {
  min-width: 82px;
  text-align: right;
  text-transform: none;
  font-size: 14px;
  font-weight: 800;
}

.template-billto {
  margin-top: 6px;
}

.template-section-title {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 2px solid #000;
  padding-bottom: 3px;
  margin-bottom: 10px;
}

.template-items-block {
  margin-top: 2px;
}

.template-items-head {
  display: flex;
  border-bottom: 2px solid #000;
  padding-bottom: 8px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
  font-size: 10px;
}

.template-items-head .col-desc {
  flex: 1;
}

.template-items-head .col-qty {
  width: 12%;
  text-align: center;
}

.template-items-head .col-rate {
  width: 18%;
  text-align: right;
}

.template-items-head .col-amt {
  width: 22%;
  text-align: right;
}

.template-totals-wrap {
  display: flex;
  justify-content: flex-end;
}

.template-center {
  justify-content: center;
}

.template-totals-box {
  width: 300px;
  border: 1px solid #000;
  padding: 12px 14px;
}

.template-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #000;
  padding: 7px 0;
  font-size: 14px;
  font-weight: 700;
}

.template-total-row:last-child {
  border-bottom: 0;
}

.template-total-final {
  margin-top: 10px;
  border-top: 2px solid #000;
  padding-top: 10px;
  font-size: 24px;
  font-weight: 900;
  text-transform: uppercase;
}

.template-total-final span:first-child {
  font-size: 13px;
}

.template-pay-block,
.template-notes {
  border-top: 1px solid #000;
  padding-top: 10px;
}

.template-notes-body {
  min-height: 52px;
}

.template-brandline {
  position: absolute;
  right: 56px;
  bottom: 24px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Preview Item Rows ── */
.preview-item-row {
  display: flex;
  align-items: flex-start;
  gap: 0;
  border-bottom: 1px solid #000;
  padding: 8px 0;
}

.preview-item-row:last-of-type {
  border-bottom: 0;
}

.preview-item-desc {
  flex: 1;
  padding-right: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview-item-qty {
  width: 12%;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.preview-item-rate {
  width: 18%;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

.preview-item-amt {
  width: 22%;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
}

/* ── Theme Variants ── */
.tpl-modern .template-meta-cards {
  display: flex;
  gap: 8px;
}

.tpl-modern .template-meta-card {
  border: 1px solid #000;
  padding: 8px 10px;
  min-width: 96px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 800;
}

.tpl-modern .template-meta-card div:last-child {
  font-size: 13px;
  margin-top: 2px;
}

.tpl-modern .template-card {
  border: 1px solid #000;
  padding: 14px;
}

.tpl-modern .template-dual-cards {
  display: flex;
  gap: 12px;
}

.tpl-modern .template-dual-cards .template-card {
  flex: 1;
}

.tpl-modern .template-bottom-split {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.tpl-modern .template-bottom-notes {
  flex: 1;
}

.tpl-agency .template-band {
  border-bottom: 2px solid #000;
  padding-bottom: 14px;
}

.tpl-agency .template-pad-x {
  padding-left: 8px;
  padding-right: 8px;
}

.tpl-editorial .template-shell,
.tpl-editorial.template-shell {
  font-family: "Times New Roman", Georgia, serif;
}

.tpl-editorial .template-center-head {
  text-align: center;
  padding-top: 6px;
}

.tpl-editorial .template-center-meta {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.tpl-editorial .template-editorial-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  border-top: 1px solid #000;
  border-bottom: 1px solid #000;
  padding: 16px 0;
}

.tpl-editorial .template-center-text {
  text-align: center;
}

.tpl-studio .template-studio-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 4px solid #000;
  padding-bottom: 8px;
}

.tpl-studio .template-title {
  font-size: 68px;
}

.tpl-studio .template-studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  border-bottom: 4px solid #000;
  padding-bottom: 12px;
}

.tpl-studio .template-meta-stack {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
}

.tpl-studio .template-totals-box {
  border-width: 4px;
}

.tpl-tech.template-shell {
  font-family: "Courier New", Consolas, monospace;
}

.tpl-tech .template-title {
  font-size: 40px;
  letter-spacing: -0.01em;
}

.tpl-tech .template-chip {
  border: 1px solid #000;
  padding: 5px 8px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.tpl-tech .template-tech-to {
  border-left: 2px solid #000;
  padding-left: 12px;
}

.tpl-tech .preview-item-row {
  border-bottom-style: dashed;
}

.template-item-modern .preview-item-desc {
  font-weight: 600;
}

.template-item-agency .preview-item-desc,
.template-item-studio .preview-item-desc {
  text-transform: uppercase;
  font-weight: 800;
}

.template-item-editorial .preview-item-desc {
  font-family: "Times New Roman", Georgia, serif;
  font-weight: 600;
}

.template-item-tech .preview-item-desc,
.template-item-tech .preview-item-qty,
.template-item-tech .preview-item-rate,
.template-item-tech .preview-item-amt {
  font-family: "Courier New", Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

.template-bottom-split {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.template-bottom-notes {
  flex: 1;
}

.tpl-midnight.template-shell {
  background: #0f0f10;
  color: #fff;
}

.tpl-midnight .template-section-title,
.tpl-midnight .template-items-head,
.tpl-midnight .template-total-row,
.tpl-midnight .template-subline,
.tpl-midnight .template-to-name,
.tpl-midnight .template-from-name,
.tpl-midnight .template-title,
.tpl-midnight .template-meta-row,
.tpl-midnight .template-brandline {
  color: #fff;
  border-color: #2a2a2c;
}

.tpl-midnight .template-totals-box,
.tpl-midnight .template-pay-block,
.tpl-midnight .template-notes,
.tpl-midnight .preview-item-row {
  border-color: #2a2a2c;
}

.tpl-vintage.template-shell {
  background: #fdfbf7;
  font-family: "Playfair Display", Georgia, serif;
}

.tpl-vintage .template-subline,
.tpl-vintage .template-meta-row {
  color: #6b6259;
}

.tpl-vintage .template-items-head,
.tpl-vintage .preview-item-row,
.tpl-vintage .template-total-row,
.tpl-vintage .template-pay-block,
.tpl-vintage .template-notes {
  border-color: #d0c6b8;
}

.tpl-saas.template-shell {
  background: #ffffff;
}

.tpl-saas .template-accent-gradient {
  background: linear-gradient(90deg, #7c3aed, #d946ef);
}

.tpl-saas .template-meta-cardline {
  display: inline-flex;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.tpl-saas .template-meta-cardline > div > div:first-child {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  font-weight: 700;
}

.tpl-saas .template-meta-cardline > div > div:last-child {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
}

.tpl-saas .template-billto-card {
  width: 62%;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
}

.tpl-saas .template-items-head {
  border-bottom: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: #f8fafc;
}

.tpl-saas .preview-item-row {
  border-bottom-color: #e2e8f0;
  padding: 9px 10px;
}

.tpl-saas .template-totals-box,
.tpl-saas .template-pay-block,
.tpl-saas .template-notes {
  border-color: #e2e8f0;
}

.tpl-saas .template-total-final span:first-child {
  color: #7c3aed;
}

.tpl-brutalist.template-shell {
  padding: 42px;
  font-family: "JetBrains Mono", "Courier New", monospace;
}

.tpl-brutalist .template-brandline {
  right: 54px;
  bottom: 54px;
}

.tpl-brutalist .template-brutal-frame {
  border: 2px solid #000;
  min-height: calc(1123px - 84px);
  display: flex;
  flex-direction: column;
}

.tpl-brutalist .template-brutal-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 2px solid #000;
}

.tpl-brutalist .template-brutal-left {
  padding: 16px;
  border-right: 2px solid #000;
}

.tpl-brutalist .template-brutal-left .template-title {
  font-size: 52px;
  margin-top: 32px;
}

.tpl-brutalist .template-brutal-right {
  display: flex;
  flex-direction: column;
}

.tpl-brutalist .template-brutal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 2px solid #000;
}

.tpl-brutalist .template-brutal-meta > div {
  padding: 10px 12px;
  border-right: 2px solid #000;
}

.tpl-brutalist .template-brutal-meta > div:last-child {
  border-right: 0;
}

.tpl-brutalist .template-brutal-meta span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #4b5563;
  font-weight: 700;
}

.tpl-brutalist .template-brutal-meta strong {
  font-size: 12px;
}

.tpl-brutalist .template-brutal-issuer {
  padding: 12px;
}

.tpl-brutalist .template-brutal-client {
  padding: 12px 16px;
  border-bottom: 2px solid #000;
}

.tpl-brutalist .template-brutal-items {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tpl-brutalist .template-items-head {
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 2px solid #000;
  margin-bottom: 0;
  padding: 0;
}

.tpl-brutalist .template-items-head > div {
  padding: 10px;
  border-right: 2px solid #000;
}

.tpl-brutalist .template-items-head > div:last-child {
  border-right: 0;
}

.tpl-brutalist .preview-item-row {
  border-bottom: 2px solid #000;
  padding: 0;
}

.tpl-brutalist .preview-item-desc,
.tpl-brutalist .preview-item-qty,
.tpl-brutalist .preview-item-rate,
.tpl-brutalist .preview-item-amt {
  padding: 10px;
  border-right: 2px solid #000;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}

.tpl-brutalist .preview-item-amt {
  border-right: 0;
}

.tpl-brutalist .template-brutal-bottom {
  display: grid;
  grid-template-columns: 1fr 320px;
  border-top: 2px solid #000;
}

.tpl-brutalist .template-brutal-bottom > div:first-child {
  border-right: 2px solid #000;
  padding: 12px;
}

.tpl-brutalist .template-totals-box {
  border: 0;
  padding: 0;
}

.tpl-brutalist .template-total-row {
  border-bottom: 2px solid #000;
  padding: 12px;
}

.tpl-brutalist .template-total-final {
  margin-top: 0;
  border-top: 0;
  background: #000;
  color: #fff;
  padding: 14px 12px;
}

.template-item-midnight .preview-item-desc,
.template-item-midnight .preview-item-qty,
.template-item-midnight .preview-item-rate,
.template-item-midnight .preview-item-amt {
  color: #fff !important;
}

.template-item-midnight.preview-item-row {
  border-bottom-color: #2a2a2c;
}

.template-item-vintage .preview-item-desc {
  font-family: "Playfair Display", Georgia, serif;
}

.template-item-vintage.preview-item-row {
  border-bottom-color: #d0c6b8;
}

.template-item-saas.preview-item-row {
  border-bottom-color: #e2e8f0;
}

.template-item-brutalist.preview-item-row {
  border-bottom-width: 2px;
}

/* ── Live Footer ── */
.live-footer {
  flex-shrink: 0;
}

/* ── Responsive: Mobile ── */
@media (max-width: 1023px) {
  .live-header-center {
    display: none;
  }

  /* Hide header download on mobile - bottom bar has it */
  .live-header-right #btn-download {
    display: none;
  }

  .mobile-action-bar {
    display: flex;
  }

  /* Layout goes vertical on mobile */
  .live-doc-layout {
    flex-direction: column;
  }

  /* Guide becomes horizontal card above invoice */
  .guide-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid #e5e7eb;
    overflow: visible;
  }

  .guide-sidebar.is-collapsed {
    margin-left: 0;
    margin-top: -200px;
    opacity: 0;
    pointer-events: none;
    position: absolute;
  }

  .guide-sidebar-inner {
    padding: 12px 16px;
    gap: 10px;
    height: auto;
  }

  .guide-header {
    display: none;
  }

  .guide-nudge {
    font-size: 11px;
    padding: 8px 10px;
  }

  .guide-sections {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    flex: none;
  }

  .guide-section {
    flex: 0 0 auto;
    width: auto;
    padding: 6px 10px;
    gap: 6px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 20px;
  }

  .guide-section:hover {
    background: #f3f4f6;
  }

  .guide-section-status {
    width: 16px;
    height: 16px;
    margin-top: 0;
  }

  .guide-section-status.is-done::after {
    width: 5px;
    height: 8px;
  }

  .guide-section-label {
    font-size: 12px;
  }

  .guide-section-hint {
    display: none;
  }

  .guide-section-content {
    gap: 0;
  }

  .guide-progress-wrap {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding-top: 6px;
    border-top: none;
  }

  .guide-progress-bar {
    flex: 1;
  }

  .guide-progress-text {
    white-space: nowrap;
  }

  .guide-expand-btn {
    display: none !important;
  }

  .live-doc-surface {
    padding: 16px 8px 100px;
  }

  .floating-total {
    bottom: 70px;
    right: 12px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .floating-total-amount {
    font-size: 1rem;
  }

  .dialog-modal {
    top: auto;
    right: 1rem;
    left: 1rem;
    bottom: calc(5.75rem + env(safe-area-inset-bottom, 0px));
    width: auto;
  }

  .live-item-delete {
    right: -4px;
    top: -8px;
    width: 22px;
    height: 22px;
  }
}

/* ── Responsive: Desktop ── */
@media (min-width: 1024px) {
  .mobile-action-bar {
    display: none !important;
  }

  .live-header {
    padding: 0 24px;
  }

  .live-doc-surface {
    padding: 48px 40px 80px;
  }
}

/* ── Print ── */
@media print {
  body > *:not(#pdf-preview) { display: none !important; }
  #pdf-preview { box-shadow: none !important; transform: none !important; }
}
