/* Free bill maker (free-bill-maker/): the form on the left, the bill as it will print on the right */
.maker { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 40px; align-items: start; padding-top: 8px; border-top: none; }
.maker fieldset { margin: 0 0 18px; padding: 18px 20px 20px; border: 1.5px solid var(--rule); border-radius: 14px; background: #fff; }
.maker legend { padding: 0 6px; margin-left: -6px; font-weight: 700; letter-spacing: -0.01em; }
.maker-hint { margin: 2px 0 12px; color: var(--grey); font-size: 0.88rem; }
.maker label { display: flex; flex-direction: column; gap: 5px; color: #2f3b4c; font-size: 0.9rem; font-weight: 600; }
.maker input, .maker textarea {
    width: 100%;
    min-height: 42px;
    padding: 8px 11px;
    border: 1px solid #c3cad5;
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font: 400 1rem var(--font);
}
.maker textarea { min-height: 0; resize: vertical; }
.maker input:focus, .maker textarea:focus { outline: none; border-color: var(--carbon); box-shadow: 0 0 0 3px rgba(39, 67, 196, 0.2); }
.maker input[type=number] { text-align: right; }
.soft { color: var(--grey); font-weight: 400; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row2 + label, label + .row2, .row2 + .row2 { margin-top: 12px; }

/* item lines */
.lines-head, .line { display: grid; grid-template-columns: minmax(0, 1fr) 76px 104px 96px 34px; gap: 8px; align-items: center; }
.lines-head { margin-bottom: 6px; color: var(--grey); font-size: 0.8rem; font-weight: 700; }
.lines-head span:nth-child(n+2) { text-align: right; }
.line + .line { margin-top: 8px; }
.line .amount { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.remove { width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: #98a2b3; font-size: 1.3rem; cursor: pointer; }
.remove:hover { background: #fbeaea; color: #cf3434; }
.add-line { margin-top: 12px; padding: 8px 14px; border: 1.5px dashed #c3cad5; border-radius: 9px; background: none; color: var(--carbon); font: 700 0.95rem var(--font); cursor: pointer; }
.add-line:hover { border-color: var(--carbon); background: #e9edfb; }
.subtotal-row { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); font-weight: 700; }

/* preview and actions */
.maker-side { position: sticky; top: 16px; }
.paper-switch { display: inline-flex; gap: 2px; margin-bottom: 12px; padding: 3px; border: 1px solid var(--rule); border-radius: 10px; background: #fff; }
.paper-switch button { padding: 6px 12px; border: 0; border-radius: 7px; background: none; color: var(--grey); font: 650 0.9rem var(--font); cursor: pointer; }
.paper-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.preview-wrap { max-height: 70vh; overflow: auto; padding: 18px; border-radius: 14px; background: #e6eaf0; }
.maker-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.maker-actions .button { padding: 11px 14px; font-size: 0.95rem; }
.maker-actions .wide { grid-column: 1 / -1; }
.maker-msg { min-height: 1.4em; margin: 10px 0 0; color: #cf3434; font-size: 0.9rem; font-weight: 600; }
.maker-msg.ok { color: #1d7a46; }
.maker-new { margin-top: 4px; padding: 0; border: 0; background: none; color: var(--carbon); font: 650 0.92rem var(--font); text-decoration: underline; cursor: pointer; }

/* The bill itself: same layout as the app's printed bills */
.paper { position: relative; margin: 0 auto; padding: 28px 30px; background: #fff; color: #1b2230; font: 400 14px/1.45 var(--font); box-shadow: 0 1px 0 #c3cad5, 0 18px 36px -24px rgba(20, 32, 46, 0.5); }
.paper-head { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 2px solid #1b2230; text-align: center; }
.paper-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 750; letter-spacing: 0.01em; text-transform: uppercase; overflow-wrap: anywhere; }
.paper-head p { margin: 1px 0; color: #475467; white-space: pre-line; }
.paper-meta { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.paper-meta p { margin: 1px 0; }
.paper table { width: 100%; border-collapse: collapse; }
.paper th { padding: 6px 4px; border-bottom: 2px solid #1b2230; font-size: 12px; text-align: left; }
.paper td { padding: 6px 4px; border-bottom: 1px solid #e6e9ee; vertical-align: top; overflow-wrap: anywhere; }
.paper .num { text-align: right; white-space: nowrap; }
.paper-totals { width: min(240px, 100%); margin: 12px 0 0 auto; }
.paper-totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.paper-totals .grand { margin-top: 4px; padding-top: 6px; border-top: 2px solid #1b2230; font-size: 17px; font-weight: 800; }
.paper-foot { margin: 22px 0 0; color: #475467; font-style: italic; text-align: center; }
.paper-credit { margin: 10px 0 0; color: #98a2b3; font-size: 11px; text-align: center; }
.paper-empty { padding: 26px 0; color: #98a2b3; text-align: center; }
.paper.receipt { max-width: 80mm; padding: 16px 14px; font: 400 12px/1.45 var(--mono); }
.paper.receipt .paper-head h2 { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.paper.receipt .paper-meta { flex-direction: column; gap: 4px; }
.paper.receipt .paper-totals { width: 100%; }
.paper.receipt .paper-totals .grand { font-size: 14px; }

@media (max-width: 980px) {
    .maker { grid-template-columns: 1fr; }
    .maker-side { position: static; }
    .preview-wrap { max-height: none; }
}
@media (max-width: 560px) {
    .maker fieldset { padding: 14px; }
    .row2 { grid-template-columns: 1fr; }
    .lines-head { display: none; }
    .line { grid-template-columns: 1fr 1fr 34px; grid-template-areas: "name name remove" "qty rate rate" "amount amount amount"; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
    .line .name { grid-area: name; }
    .line .qty { grid-area: qty; }
    .line .rate { grid-area: rate; }
    .line .amount { grid-area: amount; }
    .line .remove { grid-area: remove; }
    .maker input, .maker textarea { font-size: 16px; }
}

/* Printing: only the bill */
@media print {
    body * { visibility: hidden !important; }
    #billPaper, #billPaper * { visibility: visible !important; }
    #billPaper { position: absolute; left: 0; top: 0; box-shadow: none; margin: 0; }
    #billPaper.a4 { width: 100%; padding: 0; }
    #billPaper.receipt { width: 100%; max-width: none; padding: 0; }
    .preview-wrap { background: none; padding: 0; overflow: visible; max-height: none; }
}
