/* =========================================================
   Invoice Generator — editor + live preview
   ========================================================= */
.inv-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
}

/* Editor panel */
.inv-editor {
  
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  
  overflow-y: auto;
}
.inv-editor h3 { font-size: 1rem; margin-bottom: 4px; }
.editor-section { padding-block: 18px; border-bottom: 1px solid var(--border); }
.editor-section:last-child { border-bottom: none; }
.editor-section > .sec-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-subtle); margin-bottom: 14px;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; min-height: 62px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Logo uploader */
.logo-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--text-subtle);
  font-size: 0.85rem;
}
.logo-drop:hover, .logo-drop.drag { border-color: var(--brand); background: var(--brand-soft); }
.logo-drop img { max-height: 60px; margin-inline: auto; border-radius: 6px; }

/* Editable line items in editor */
.li-row {
  display: grid;
  grid-template-columns: 1fr 62px 82px 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.li-row input { padding: 8px 9px; font-size: 0.85rem; }
.li-del {
  width: 30px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--danger); background: rgba(239,68,68,0.08);
  transition: background 0.2s;
}
.li-del:hover { background: rgba(239,68,68,0.18); }
.li-del svg { width: 16px; height: 16px; }
.li-head {
  display: grid; grid-template-columns: 1fr 62px 82px 30px; gap: 8px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-subtle); margin-bottom: 6px; letter-spacing: 0.04em;
}

/* Theme swatches */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: transform 0.15s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }

/* ---------- Preview / paper ---------- */
.inv-preview-wrap { position: relative; }
.inv-toolbar {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px; align-items: center;
}
.inv-toolbar .spacer { flex: 1; }

.paper {
  background: #fff;
  color: #1a1a1a;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px; /* Mobile base padding */
  max-width: 800px;
  margin-inline: auto;
  --accent: #2563eb;
  font-size: 12px; /* Sized for mobile viewport */
  line-height: 1.4;
  box-sizing: border-box;
}
.paper .pv-top {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--accent);
}
.paper .pv-brand h2 { font-size: 1.5rem; color: var(--accent); margin-bottom: 4px; }
.paper .pv-brand .from { color: #555; font-size: 0.85rem; white-space: pre-line; }
.paper .pv-logo img { max-height: 72px; max-width: 200px; }
.paper .pv-title { text-align: left; }
.paper .pv-title .word { font-size: 2rem; font-weight: 800; letter-spacing: 0.04em; color: #111; text-transform: uppercase; }
.paper .pv-title .meta { color: #555; font-size: 0.85rem; margin-top: 8px; }
.paper .pv-title .meta b { color: #111; }

.paper .pv-parties { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.paper .pv-parties .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: #999; font-weight: 700; margin-bottom: 6px; }
.paper .pv-parties .val { white-space: pre-line; color: #333; }
.paper .pv-parties .name { font-weight: 700; color: #111; font-size: 1rem; }

.paper table { width: 100%; border-collapse: collapse; margin-top: 20px; table-layout: fixed; }
.paper thead th {
  background: var(--accent); color: #fff; text-align: left;
  padding: 8px 10px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em;
  word-wrap: break-word; overflow-wrap: break-word;
}

.paper thead th.num, .paper tbody td.num { text-align: right; }
.paper th:nth-child(1), .paper td:nth-child(1) { width: 45%; }
.paper th:nth-child(2), .paper td:nth-child(2) { width: 15%; }
.paper th:nth-child(3), .paper td:nth-child(3) { width: 20%; }
.paper th:nth-child(4), .paper td:nth-child(4) { width: 20%; }

.paper tbody td { padding: 8px 10px; border-bottom: 1px solid #eee; color: #333; word-wrap: break-word; overflow-wrap: break-word; }
.paper tbody tr:nth-child(even) { background: #fafafa; }

.paper .pv-totals { display: flex; justify-content: flex-end; margin-top: 24px; }
.paper .pv-totals table { width: 300px; margin-top: 0; }
.paper .pv-totals td { border: none; padding: 6px 4px; }
.paper .pv-totals td.num { text-align: right; }
.paper .pv-totals .grand td {
  border-top: 2px solid var(--accent); font-size: 1.15rem;
  font-weight: 800; color: var(--accent); padding-top: 12px;
}
.paper .pv-notes { margin-top: 32px; padding-top: 20px; border-top: 1px solid #eee; }
.paper .pv-notes .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: #999; font-weight: 700; margin-bottom: 6px; }
.paper .pv-notes p { color: #555; white-space: pre-line; font-size: 0.85rem; }
.paper .pv-footer { margin-top: 30px; text-align: center; color: #aaa; font-size: 0.78rem; }

/* Template variants */
.paper.tpl-modern .pv-top { border-bottom-width: 3px; }
.paper.tpl-classic { --radius: 0; }
.paper.tpl-classic .pv-top { border-bottom: 2px solid #111; }
.paper.tpl-classic thead th { background: #111; }
.paper.tpl-classic .pv-title .word { color: var(--accent); }
.paper.tpl-minimal .pv-top { border-bottom: 1px solid #e5e5e5; }
.paper.tpl-minimal thead th { background: transparent; color: #111; border-bottom: 2px solid var(--accent); }
.paper.tpl-minimal .pv-title .word { font-weight: 600; }


@media (min-width: 481px) {
  .paper {
    padding: 30px;
    font-size: 14px;
    line-height: 1.5;
  }
  .paper .pv-top {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 28px;
  }
  .paper .pv-title {
    text-align: right;
  }
  .paper .pv-parties {
    flex-direction: row;
    justify-content: space-between;
    margin-top: 28px;
  }
  .paper table {
    margin-top: 28px;
  }
  .paper thead th {
    padding: 11px 14px;
    font-size: 0.78rem;
  }
  .paper tbody td {
    padding: 12px 14px;
  }
}

@media (min-width: 1025px) {
  .inv-layout { grid-template-columns: 420px 1fr; }
  .inv-editor { position: sticky; top: 88px; max-height: calc(100vh - 108px); }
  .paper { padding: 48px; }
}

  .inv-editor { position: static; max-height: none; 