/* ─── App Layout ─────────────────────────────────── */
.app-body {
  background: #f2f1ee;
  min-height: 100vh;
}

.app-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: calc(100vh - 60px);
}

/* ─── Form Panel ─────────────────────────────────── */
.form-panel {
  background: #fff;
  border-right: 1px solid #e4e2dc;
  padding: 28px 28px 60px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}

.panel-title {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
  color: #0e0e0e;
  margin-bottom: 24px;
}

.form-section {
  margin-bottom: 14px;
}

.form-section label,
.section-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9a9a9a;
  margin-bottom: 5px;
}

.section-label { margin-bottom: 10px; }

.form-section input,
.form-section textarea,
.form-section select {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: #0e0e0e;
  background: #faf9f6;
  border: 1px solid #e4e2dc;
  border-radius: 6px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
}

.form-section input:focus,
.form-section textarea:focus,
.form-section select:focus {
  border-color: #0e0e0e;
  background: #fff;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.form-row.form-row-2 {
  grid-template-columns: repeat(2, 1fr);
}

.divider {
  height: 1px;
  background: #e4e2dc;
  margin: 18px 0;
}

/* ─── Line Items ─────────────────────────────────── */
.line-item {
  display: grid;
  grid-template-columns: 1fr 60px 80px 24px;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

.line-item input {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: #0e0e0e;
  background: #faf9f6;
  border: 1px solid #e4e2dc;
  border-radius: 6px;
  padding: 8px 10px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.line-item input:focus {
  border-color: #0e0e0e;
  background: #fff;
}

.btn-remove {
  background: none;
  border: none;
  color: #ccc;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: color 0.15s;
}

.btn-remove:hover { color: #d0453a; }

.btn-add {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #5a5a5a;
  background: none;
  border: 1px dashed #d0cdc6;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
  margin-top: 4px;
}

.btn-add:hover {
  border-color: #0e0e0e;
  color: #0e0e0e;
}

/* ─── Preview Panel ──────────────────────────────── */
.preview-panel {
  padding: 32px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a9a9a;
  margin-bottom: 16px;
  align-self: flex-start;
}

/* ─── Invoice Preview ────────────────────────────── */
.invoice-preview {
  background: #fff;
  width: 100%;
  max-width: 680px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e4e2dc;
  font-family: 'DM Sans', sans-serif;
}

.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 36px 36px 24px;
  background: #1a1a2e;
  color: #fff;
}

.inv-logo-text {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: #fff;
}

.inv-from-detail {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
  white-space: pre-line;
}

.inv-meta { text-align: right; }

.inv-title-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-bottom: 16px;
}

.inv-label-word {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 2px;
}

.inv-num {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: #fff;
  letter-spacing: -0.01em;
}

.inv-dates { display: flex; flex-direction: column; gap: 4px; }

.inv-date-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

.inv-date-row span:last-child { color: rgba(255,255,255,0.85); min-width: 90px; text-align: right; }

/* Bill to */
.inv-bill { padding: 20px 36px; border-bottom: 1px solid #e4e2dc; }

.inv-bill-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #9a9a9a;
  margin-bottom: 6px;
}

.inv-bill-name { font-size: 15px; font-weight: 500; color: #0e0e0e; margin-bottom: 2px; }

.inv-bill-detail {
  font-size: 12px;
  color: #5a5a5a;
  line-height: 1.5;
  white-space: pre-line;
}

/* Table */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.inv-table thead tr {
  background: #f7f6f3;
}

.inv-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9a9a9a;
  padding: 10px 14px;
  border-bottom: 1px solid #e4e2dc;
}

.inv-table th:not(:first-child),
.inv-table td:not(:first-child) {
  text-align: right;
}

.inv-table td {
  padding: 11px 14px;
  color: #0e0e0e;
  border-bottom: 1px solid #f0eeea;
  vertical-align: top;
}

.inv-table td:first-child { color: #0e0e0e; }
.inv-table td.desc-secondary { font-size: 11px; color: #9a9a9a; }

/* Totals */
.inv-totals {
  padding: 16px 36px;
  border-top: 1px solid #e4e2dc;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.inv-total-row {
  display: flex;
  gap: 48px;
  font-size: 13px;
  color: #5a5a5a;
  min-width: 240px;
  justify-content: space-between;
}

.inv-total-final {
  font-size: 16px;
  font-weight: 500;
  color: #0e0e0e;
  border-top: 1px solid #e4e2dc;
  padding-top: 8px;
  margin-top: 4px;
}

/* Notes */
.inv-notes {
  padding: 0 36px 20px;
  font-size: 12px;
  color: #9a9a9a;
  line-height: 1.6;
  white-space: pre-line;
  min-height: 0;
}

.inv-notes:not(:empty) { padding-top: 4px; }

/* Footer bar */
.inv-footer-bar {
  background: #f7f6f3;
  border-top: 1px solid #e4e2dc;
  padding: 10px 36px;
  font-size: 11px;
  color: #bbb;
  text-align: center;
}

/* ─── Preview Actions ────────────────────────────── */
.preview-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  align-self: flex-start;
}

.btn-download {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 28px;
  background: #0e0e0e;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}

.btn-download:hover { opacity: 0.85; transform: translateY(-1px); }

/* ─── Logo Upload ────────────────────────────────── */
.logo-upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

#logoPreviewThumb {
  max-height: 36px;
  max-width: 120px;
  object-fit: contain;
  border-radius: 4px;
}

.btn-logo-upload {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #5a5a5a;
  background: none;
  border: 1px dashed #d0cdc6;
  border-radius: 6px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logo-upload:hover { border-color: #0e0e0e; color: #0e0e0e; }

.btn-logo-clear {
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  color: #9a9a9a;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.btn-logo-clear:hover { color: #d0453a; }

/* ─── Invoice Logo ───────────────────────────────── */
.inv-logo-img {
  max-height: 48px;
  max-width: 160px;
  object-fit: contain;
  margin-bottom: 10px;
}

/* ─── Secondary Action Buttons ───────────────────── */
.btn-action-secondary {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  background: #fff;
  color: #0e0e0e;
  border: 1px solid #e4e2dc;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.btn-action-secondary:hover { border-color: #0e0e0e; transform: translateY(-1px); }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
  }
  .form-panel {
    position: static;
    max-height: none;
  }
  .preview-panel {
    max-height: none;
  }
}

/* ─── Print ──────────────────────────────────────── */
@media print {
  .nav, .form-panel, .preview-label, .preview-actions { display: none !important; }
  body, .app-body { background: #fff; }
  .app-layout { display: block; }
  .preview-panel { padding: 0; max-height: none; overflow: visible; }
  .invoice-preview { max-width: 100%; border: none; border-radius: 0; box-shadow: none; }
}
