/* ==========================================================================
   PINVOICE — FREE TOOLS
   Calculators and document generators. The document preview is a light,
   paper-like surface on purpose: it is what gets printed to PDF.
   ========================================================================== */

.pv-tool {
  display: grid;
  gap: 24px;
  margin-top: 8px;
}

.pv-tool-doc {
  grid-template-columns: minmax(320px, 460px) 1fr;
  align-items: start;
}

@media (max-width: 1024px) {
  .pv-tool-doc {
    display: flex;
    flex-direction: column;
  }
  .pv-doc {
    width: 100%;
    padding: 12px;
  }
}

/* ---- Form ---------------------------------------------------------------- */
.pv-tool-form {
  display: grid;
  gap: 14px;
  padding: 24px;
  background: var(--pv-card-2);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-r-card);
}

.pv-tool-legend {
  margin: 6px 0 0 !important;
  color: var(--pv-accent-text) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.pv-f {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--pv-text-3);
}

.pv-f input,
.pv-f select,
.pv-line input,
.pv-line select {
  width: 100%;
  padding: 10px 12px;
  background: var(--pv-page);
  border: 1px solid var(--pv-border-2);
  border-radius: var(--pv-r-menu);
  color: var(--pv-text);
  font-family: var(--pv-font-body);
  font-size: 14px;
}

.pv-f input:focus,
.pv-f select:focus,
.pv-line input:focus,
.pv-line select:focus {
  outline: 2px solid var(--pv-accent);
  outline-offset: 1px;
  color: var(--pv-text);
}

.pv-f-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pv-f-check input {
  width: auto;
  accent-color: var(--pv-accent);
}

.pv-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pv-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

@media (max-width: 575px) {
  .pv-grid2, .pv-grid3 { grid-template-columns: 1fr; }
}

/* ---- Segmented control --------------------------------------------------- */
.pv-seg {
  display: flex;
  padding: 4px;
  background: var(--pv-page);
  border: 1px solid var(--pv-border-2);
  border-radius: var(--pv-r-menu);
}

.pv-seg button {
  flex: 1;
  padding: 9px 12px;
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--pv-text-3);
  font-family: var(--pv-font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.pv-seg button.is-on {
  background: var(--pv-accent);
  color: #fff;
}

/* ---- Results ------------------------------------------------------------- */
.pv-tool-out {
  margin: 0;
  padding: 24px;
  background: var(--pv-card-2);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-r-card);
}

.pv-tool-out > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--pv-border);
}

.pv-tool-out > div:last-child { border-bottom: 0; }

.pv-tool-out dt {
  color: var(--pv-text-3);
  font-size: 14px;
}

.pv-tool-out dd {
  margin: 0;
  color: var(--pv-text);
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pv-tool-out .pv-total dt { color: var(--pv-text); font-weight: 600; }

.pv-tool-out .pv-total dd {
  color: var(--pv-accent-text);
  font-family: var(--pv-font-head);
  font-size: 22px;
  font-weight: 800;
}

.pv-tool-note {
  margin: 0 !important;
  color: var(--pv-text-3) !important;
  font-size: 12px !important;
}

/* ---- Line items ---------------------------------------------------------- */
.pv-line-head,
.pv-line {
  display: grid;
  grid-template-columns: 2fr 1fr 0.6fr 1fr 0.8fr 32px;
  gap: 8px;
  align-items: center;
}

.pv-line-head {
  color: var(--pv-text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.pv-lines { display: grid; gap: 8px; }

.pv-line input,
.pv-line select { padding: 8px 10px; font-size: 13px; }

.pv-line-x {
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--pv-border-2);
  border-radius: 6px;
  color: var(--pv-text-3);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.pv-line-x:hover { border-color: var(--pv-red-solid); color: var(--pv-red-solid); }

@media (max-width: 767px) {
  .pv-line-head { display: none; }
  .pv-line {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border: 1px solid var(--pv-border);
    border-radius: var(--pv-r-menu);
  }
}

.pv-btn-ghost {
  justify-self: start;
  padding: 9px 14px;
  background: var(--pv-accent-tint);
  border: 1px dashed var(--pv-brand-border);
  border-radius: var(--pv-r-menu);
  color: var(--pv-accent-text);
  font-family: var(--pv-font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pv-btn-primary {
  padding: 12px 22px;
  background: var(--pv-brand);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--pv-r-btn);
  color: #ffffff;
  font-family: var(--pv-font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.pv-btn-primary:hover {
  background: var(--pv-brand-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

/* ---- Document preview ---------------------------------------------------- */
.pv-doc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.pv-doc {
  padding: 12px;
  background: #fff;
  border-radius: var(--pv-r-card);
  box-shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.7);
  color: #1a1b1e;
  font-size: 13px;
  line-height: 1.5;
}

.pv-doc p { margin: 2px 0; color: #495057; }

.pv-doc-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 2px solid #1a1b1e;
}

.pv-doc-head h4 {
  margin: 0 0 4px;
  color: #1a1b1e;
  font-family: var(--pv-font-head);
  font-size: 18px;
  font-weight: 800;
}

.pv-doc-title { text-align: right; }

.pv-doc-title strong {
  display: block;
  margin-bottom: 4px;
  font-family: var(--pv-font-head);
  font-size: 20px;
  letter-spacing: 0.04em;
}

.pv-doc-party { padding: 16px 0; }

.pv-doc-party h5 {
  margin: 0 0 4px;
  color: #868e96;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pv-doc-table {
  width: 100%;
  margin: 8px 0 16px;
  border-collapse: collapse;
}

.pv-doc-table th,
.pv-doc-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #dee2e6;
  text-align: left;
}

.pv-doc-table th {
  color: #868e96;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pv-doc-table .r { text-align: right; font-variant-numeric: tabular-nums; }

.pv-doc-totals { display: flex; justify-content: flex-end; }

.pv-doc-totals dl { width: 260px; margin: 0; }

.pv-doc-totals dl > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
}

.pv-doc-totals dt { color: #495057; }

.pv-doc-totals dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.pv-doc-totals .pv-total {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 2px solid #1a1b1e;
  font-weight: 700;
  font-size: 15px;
}

.pv-doc-foot {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #dee2e6;
  color: #495057;
  white-space: pre-wrap;
}

/* ---- Print: isolate the document ---------------------------------------- */
@media print {
  body.pv-printing * { visibility: hidden !important; }

  body.pv-printing #pv-doc,
  body.pv-printing #pv-doc * { visibility: visible !important; }

  body.pv-printing #pv-doc {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
  }

  @page { margin: 16mm; }
}

@media (prefers-reduced-motion: reduce) {
  .pv-seg button { transition: none; }
}
