.bill-generator-page {
    --bill-ink: #17263b;
    --bill-muted: #5c6b82;
    --bill-border: #e1e6ee;
    --bill-accent: #1f4fd8;
    --bill-accent-soft: #eef3ff;
    --bill-surface: #ffffff;
    --bill-bg: #f4f6fa;
    --bill-danger: #b3261e;
    background: var(--bill-bg);
    color: var(--bill-ink);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}
.bill-generator-page .navbar { padding: 14px 24px; border-bottom: 1px solid var(--bill-border); background: var(--bill-surface); }
.bill-generator-page .navbar a { color: var(--bill-ink); font-weight: 700; text-decoration: none; font-size: 15px; }

.bill-shell { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; }

.bill-intro { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.bill-eyebrow { text-transform: uppercase; font-size: 11px; letter-spacing: .1em; color: var(--bill-accent); font-weight: 700; margin: 0 0 6px; }
.bill-intro h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: -.01em; }
.bill-lede { margin: 0; max-width: 58ch; color: var(--bill-muted); line-height: 1.55; }
.bill-privacy { background: var(--bill-accent-soft); border: 1px solid #d6e2ff; border-radius: 12px; padding: 14px 18px; max-width: 300px; font-size: 13.5px; line-height: 1.5; color: #2a3b56; }
.bill-privacy strong { display: block; margin-bottom: 4px; color: var(--bill-ink); }

.bill-actionbar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-bottom: 22px; padding: 10px 14px; background: var(--bill-surface);
    border: 1px solid var(--bill-border); border-radius: 12px;
    position: sticky; top: 10px; z-index: 5;
}
.bill-status { font-size: 13px; color: var(--bill-muted); margin-inline-start: auto; padding: 4px 10px; border-radius: 999px; background: #f1f3f7; }
.bill-status.is-ready { background: #e5f7ec; color: #146c3a; }
.bill-status.is-error { background: #fdecea; color: var(--bill-danger); }
.bill-button {
    border: 1px solid var(--bill-border); background: var(--bill-surface); color: var(--bill-ink);
    padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.bill-button:hover { background: #f6f8fb; }
.bill-button-primary { background: var(--bill-accent); border-color: var(--bill-accent); color: #fff; }
.bill-button-primary:hover { background: #1a41b3; }

.bill-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }

.bill-panel { background: var(--bill-surface); border: 1px solid var(--bill-border); border-radius: 12px; margin-bottom: 14px; padding: 2px 18px; }
.bill-panel > summary { padding: 14px 0; font-weight: 700; font-size: 14.5px; cursor: pointer; list-style: none; display: flex; align-items: center; }
.bill-panel > summary::-webkit-details-marker { display: none; }
.bill-panel > summary::before { content: '▸'; display: inline-block; margin-inline-end: 8px; color: var(--bill-muted); transition: transform .12s ease; font-size: 11px; }
.bill-panel[open] > summary::before { transform: rotate(90deg); }
.bill-panel-body { padding: 2px 0 18px; display: flex; flex-direction: column; gap: 14px; }
.bill-field-grid { display: grid; gap: 12px; }
.bill-field-grid.two { grid-template-columns: 1fr 1fr; }
.bill-panel-body label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--bill-muted); }
.bill-panel-body input, .bill-panel-body select, .bill-panel-body textarea {
    border: 1px solid var(--bill-border); border-radius: 8px; padding: 9px 11px; font-size: 14px;
    font-family: inherit; font-weight: 400; color: var(--bill-ink); background: #fff;
}
.bill-panel-body input:focus, .bill-panel-body select:focus, .bill-panel-body textarea:focus {
    outline: none; border-color: var(--bill-accent); box-shadow: 0 0 0 3px var(--bill-accent-soft);
}
.bill-conditional[hidden] { display: none; }

.bill-item-row { display: grid; grid-template-columns: minmax(0, 2fr) 64px 90px 96px 34px; gap: 12px; align-items: center; }
.bill-item-row + .bill-item-row, div[data-bill-items] .bill-item-row + .bill-item-row { margin-top: 12px; }
.bill-item-row-header { padding: 0 0 2px; }
.bill-item-row-header span { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--bill-muted); }
.bill-item-row input { width: 100%; }
.bill-item-amount { font-size: 13.5px; font-weight: 600; text-align: right; color: var(--bill-ink); }
.bill-item-remove {
    border: 1px solid transparent; background: transparent; color: var(--bill-muted); font-size: 18px; line-height: 1; cursor: pointer;
    width: 30px; height: 30px; border-radius: 6px; justify-self: center;
}
.bill-item-remove:hover { background: #fdecea; color: var(--bill-danger); }

.bill-preview-workspace { position: sticky; top: 10px; }
.bill-preview-toolbar { margin-bottom: 10px; font-size: 13px; font-weight: 700; color: var(--bill-muted); text-transform: uppercase; letter-spacing: .04em; }
.bill-preview-frame { background: #e9edf4; border-radius: 14px; padding: 20px; overflow: auto; }
.bill-page { background: #fff; border-radius: 10px; padding: 30px; min-height: 400px; box-shadow: 0 1px 3px rgba(23, 38, 59, .08), 0 8px 24px rgba(23, 38, 59, .06); font-size: 14px; }
.bill-page[dir="rtl"] { text-align: right; }
.bill-page-header { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--bill-ink); padding-bottom: 14px; margin-bottom: 18px; }
.bill-page-title { margin: 0 0 2px; font-size: 21px; letter-spacing: -.01em; }
.bill-page-phone { font-size: 13px; color: var(--bill-muted); }
.bill-page-meta { font-size: 13px; color: var(--bill-muted); text-align: right; line-height: 1.7; }
.bill-page[dir="rtl"] .bill-page-meta { text-align: left; }
.bill-page-parties { margin-bottom: 16px; font-size: 13.5px; }
.bill-page-customer { color: var(--bill-ink); }

.bill-items-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.bill-items-table th, .bill-items-table td { border-bottom: 1px solid var(--bill-border); padding: 9px 8px; font-size: 13px; text-align: left; }
.bill-items-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--bill-muted); font-weight: 700; border-bottom: 2px solid var(--bill-border); }
.bill-page[dir="rtl"] .bill-items-table th, .bill-page[dir="rtl"] .bill-items-table td { text-align: right; }
.bill-numeric { text-align: right !important; }
.bill-page[dir="rtl"] .bill-numeric { text-align: left !important; }

.bill-totals { margin-left: auto; width: 280px; font-size: 13.5px; border-collapse: collapse; }
.bill-page[dir="rtl"] .bill-totals { margin-left: 0; margin-right: auto; }
.bill-totals tr td { padding: 6px 0; }
.bill-totals .bill-grand-total td { font-weight: 700; font-size: 15px; border-top: 1px solid var(--bill-ink); padding-top: 10px; }
.bill-balance-positive td { color: var(--bill-danger); font-weight: 700; }
.bill-balance-positive { background: #fdecea; }
.bill-balance-positive td { padding-left: 8px; padding-right: 8px; border-radius: 6px; }

.bill-payment-line { margin: 14px 0 0; font-size: 12.5px; color: var(--bill-muted); border-top: 1px dashed var(--bill-border); padding-top: 12px; }

.bill-about { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--bill-border); font-size: 14.5px; color: var(--bill-muted); max-width: 78ch; line-height: 1.6; }
.bill-about h2 { color: var(--bill-ink); font-size: 20px; }
.bill-about a { color: var(--bill-accent); font-weight: 600; }

@media (max-width: 900px) {
    .bill-workspace { grid-template-columns: 1fr; }
    .bill-preview-workspace { position: static; }
    .bill-field-grid.two { grid-template-columns: 1fr; }
    .bill-item-row { grid-template-columns: 1fr 1fr; }
    .bill-item-row-header { display: none; }
    .bill-actionbar { position: static; }
}
@media print {
    .navbar, .bill-intro, .bill-actionbar, .bill-editor, .bill-about, footer { display: none !important; }
    .bill-preview-workspace, .bill-preview-frame { position: static; background: none; padding: 0; }
    .bill-page { box-shadow: none; border-radius: 0; }
}
