/* TinyInvoice — editor and invoice-paper styles, incl. print. */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}

.topbar .right { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

body.pro .badge.free-badge { display: none; }
.badge.pro-badge { display: none; background: var(--accent); color: #fff; border-color: var(--accent); }
body.pro .badge.pro-badge { display: inline-block; }

.upgrade-note {
  display: block;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  text-align: center;
  padding: 8px 16px;
}

.upgrade-note a { font-weight: 600; }

body.pro .upgrade-note { display: none; }

/* ---------- Layout ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 0;
  min-height: calc(100vh - 61px);
}

.panel {
  border-right: 1px solid var(--line);
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 61px);
}

.preview-area {
  background: var(--surface);
  padding: 32px 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  max-height: calc(100vh - 61px);
}

/* ---------- Form ---------- */
.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 24px 0 10px;
}

.panel h2:first-child { margin-top: 0; }

.field { margin-bottom: 10px; }

.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }

.field input, .field textarea, .field select {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}

.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea { resize: vertical; min-height: 52px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Line items */
.item-row {
  display: grid;
  grid-template-columns: 1fr 56px 76px 28px;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.item-row input {
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  font-family: var(--font);
}

.item-row input:focus { outline: none; border-color: var(--accent); }

.item-row .remove {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.item-row .remove:hover { color: #dc2626; }

.add-item {
  background: none;
  border: 1px dashed var(--line);
  border-radius: 8px;
  width: 100%;
  padding: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
}

.add-item:hover { border-color: var(--accent); color: var(--accent); }

/* Pro-only fields */
.pro-field { position: relative; }

body:not(.pro) .pro-field input { pointer-events: none; opacity: 0.5; }

.pro-lock {
  display: none;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

body:not(.pro) .pro-lock { display: inline; }

/* Saved invoices */
.saved-list { list-style: none; }

.saved-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}

.saved-list button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font);
}

.saved-list .del { color: var(--muted); }
.saved-list .del:hover { color: #dc2626; }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Invoice paper ---------- */
.paper {
  background: #fff;
  width: 100%;
  max-width: 640px;
  min-height: 820px;
  padding: 48px;
  box-shadow: 0 2px 24px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.paper-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 40px; }

.paper-head .title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--paper-accent, var(--accent)); }

.paper-head .number { color: var(--muted); font-size: 13px; margin-top: 2px; }

.paper-logo { max-height: 56px; max-width: 160px; object-fit: contain; }

.paper-parties { display: flex; gap: 40px; margin-bottom: 32px; }

.paper-parties .party { flex: 1; }

.paper-parties h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.paper-parties .name { font-weight: 600; }

.paper-parties .details { white-space: pre-line; color: var(--muted); font-size: 13px; }

.paper-meta { display: flex; gap: 40px; margin-bottom: 28px; font-size: 13px; }

.paper-meta div span { display: block; }

.paper-meta .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }

.paper table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }

.paper th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 2px solid var(--ink);
  padding: 8px 4px;
}

.paper th:nth-child(2), .paper td:nth-child(2),
.paper th:nth-child(3), .paper td:nth-child(3),
.paper th:nth-child(4), .paper td:nth-child(4) { text-align: right; }

.paper td { padding: 10px 4px; border-bottom: 1px solid var(--line); }

.paper-totals { margin-left: auto; width: 240px; font-size: 14px; }

.paper-totals .row { display: flex; justify-content: space-between; padding: 4px 0; }

.paper-totals .grand {
  font-weight: 700;
  font-size: 17px;
  border-top: 2px solid var(--ink);
  margin-top: 6px;
  padding-top: 10px;
  color: var(--paper-accent, var(--accent));
}

.paper-notes { margin-top: 32px; font-size: 13px; color: var(--muted); white-space: pre-line; }

.paper-notes h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.watermark {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  font-size: 11px;
  color: #a1a1aa;
}

body.pro .watermark { display: none; }

/* ---------- Print: only the paper ---------- */
@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .preview-area { padding: 0; max-height: none; overflow: visible; }
  .paper {
    position: absolute;
    inset: 0;
    max-width: none;
    box-shadow: none;
    border-radius: 0;
    min-height: auto;
  }
}

@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; }
  .panel { border-right: none; border-bottom: 1px solid var(--line); max-height: none; }
  .preview-area { max-height: none; }
}
