.bg-app { max-width: 1000px; margin: 0 auto; padding: 0 16px 40px; }
.bg-app h1 { font-size: 1.5rem; font-weight: 700; margin: 24px 0 16px; }

.studio { display: flex; gap: 24px; align-items: flex-start; }
.studio .preview { flex: 1; min-width: 0; position: sticky; top: 16px; }
.studio .panel { flex: 0 0 400px; }

.preview-empty { padding: 32px 24px; text-align: center; color: #666; border: 2px dashed #ddd; border-radius: 8px; }
.preview-live { border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; }

.summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.sum-card { background: #f0f5fc; border-radius: 6px; padding: 12px; }
.sum-label { font-size: .75rem; color: #666; text-transform: uppercase; letter-spacing: .04em; }
.sum-value { font-size: 1.25rem; font-weight: 700; color: #2563a8; margin-top: 2px; }
.sum-value.surplus { color: #166534; }
.sum-value.deficit { color: #b91c1c; }

.cat-breakdown { margin-bottom: 16px; }
.cat-breakdown h3 { font-size: .85rem; font-weight: 600; margin: 0 0 8px; }
.cat-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: .8rem; }
.cat-name { width: 100px; text-align: right; color: #555; flex-shrink: 0; }
.cat-fill-wrap { flex: 1; height: 18px; background: #f0f0f0; border-radius: 3px; overflow: hidden; }
.cat-fill { height: 100%; background: #2563a8; border-radius: 3px; transition: width .2s; }
.cat-amt { width: 80px; color: #333; font-weight: 500; }

.sheet-preview { border: 1px solid #e0e0e0; border-radius: 6px; overflow: hidden; }
.sheet-preview table { width: 100%; border-collapse: collapse; font-size: .78rem; }
.sheet-preview th { background: #2563a8; color: #fff; padding: 6px 8px; text-align: left; font-weight: 600; }
.sheet-preview td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; }
.sheet-preview tr:last-child td { border-bottom: 0; }
.sheet-preview .cat-head td { background: #eef2f7; font-weight: 600; color: #2563a8; }
.sheet-preview .total-row td { border-top: 2px solid #2563a8; font-weight: 700; }
.sheet-preview .leftover td { font-weight: 700; font-size: .85rem; }
.sheet-preview .leftover .surplus { color: #166534; }
.sheet-preview .leftover .deficit { color: #b91c1c; }

/* Inputs */
.section-h { font-size: .95rem; font-weight: 700; margin: 18px 0 8px; color: #2563a8; }

.income-rows, .expense-rows { display: flex; flex-direction: column; gap: 6px; }
.inc-row, .exp-row { display: flex; gap: 6px; align-items: flex-start; }
.inc-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; flex: 1; min-width: 0; }
.exp-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; flex: 1; min-width: 0; }
.inc-f, .exp-f { display: block; min-width: 0; }
.inc-f span, .exp-f span { display: block; margin: 0 0 3px; font-size: 12px; font-weight: 600; color: #52606d; }
.inc-f input, .inc-f select, .exp-f input, .exp-f select {
  font-size: .9rem; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px;
  width: 100%; box-sizing: border-box; background: #fff;
}
.inc-f input:focus, .inc-f select:focus, .exp-f input:focus, .exp-f select:focus {
  border-color: #2563a8; outline: none; box-shadow: 0 0 0 2px rgba(37,99,168,.15);
}
.row-remove { background: none; border: none; font-size: 1.2rem; color: #999; cursor: pointer; padding: 8px 4px; line-height: 1; margin-top: 17px; }
.row-remove:hover { color: #c00; }

.add-row { font-size: .85rem; color: #2563a8; text-decoration: none; display: inline-block; margin: 4px 0 12px; }
.add-row:hover { text-decoration: underline; }

.ctrl { margin-bottom: 14px; }
.ctrl label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 4px; color: #333; }
.ctrl input, .ctrl select {
  font-size: .9rem; padding: 8px 10px; border: 1px solid #ccc; border-radius: 4px;
  width: 100%; box-sizing: border-box;
}
.ctrl input:focus, .ctrl select:focus { border-color: #2563a8; outline: none; box-shadow: 0 0 0 2px rgba(37,99,168,.15); }

a.dl,
a.dl-again { display: inline-block; padding: 12px 28px; background: #2563a8; color: #fff; border-radius: 6px; text-decoration: none; font-weight: 600; font-size: 1rem; text-align: center; }
a.dl:hover { background: #1e529a; }
a.dl-again { background: #f5f5f5; color: #333; font-size: .85rem; padding: 8px 18px; }
a.dl-again:hover { background: #eee; }

#buy { display: block; text-align: center; width: 100%; box-sizing: border-box; margin-top: 8px; }
#buy.inert { opacity: .4; pointer-events: none; }

/* Order page */
.order { max-width: 480px; margin: 40px auto; text-align: center; }
.order h1 { font-size: 1.5rem; }
.order .dl, .order .dl-again { display: block; width: max-content; max-width: 100%; box-sizing: border-box; margin: 0 auto 12px; }
.new-plan { display: inline-block; color: #2563a8; font-size: .85rem; text-decoration: none; margin-top: 8px; }
.new-plan:hover { text-decoration: underline; }
.sent { font-size: .85rem; color: #666; margin-top: 20px; }

/* Paywall */
.bg-pay { max-width: 1000px; margin: 0 auto; padding: 0 16px 40px; }
.bg-back { font-size: .85rem; color: #2563a8; text-decoration: none; display: inline-block; margin: 16px 0 12px; }
.bg-back:hover { text-decoration: underline; }
.pay-grid { display: flex; gap: 24px; align-items: flex-start; }
.pay-art { flex: 1; min-width: 0; }
.pay-art h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 12px; }
.pp-sheet { position: relative; border: 1px solid #d0d5dd; border-radius: 6px; overflow: hidden; }
.pp-wm { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 3rem; font-weight: 800; color: rgba(37,99,168,.10); letter-spacing: .15em; pointer-events: none; transform: rotate(-18deg); z-index: 1; }
.pp-sheet table { width: 100%; border-collapse: collapse; font-size: .72rem; position: relative; z-index: 0; }
.pp-sheet td { padding: 4px 8px; border-bottom: 1px solid #f0f0f0; }
.pp-sheet .pp-r { text-align: right; font-variant-numeric: tabular-nums; }
.pp-sheet .pp-sec td { background: #2563a8; color: #fff; font-weight: 700; font-size: .78rem; padding: 6px 8px; }
.pp-sheet .pp-hd td { background: #eef2f7; font-weight: 600; font-size: .68rem; color: #555; text-transform: uppercase; letter-spacing: .03em; }
.pp-sheet .pp-cat td { background: #f8f9fb; font-weight: 600; color: #2563a8; font-size: .7rem; }
.pp-sheet .pp-tot td { border-top: 2px solid #2563a8; font-weight: 700; }
.pp-sheet .pp-lo td { font-weight: 700; font-size: .78rem; }
.pp-sheet .pp-lo .surplus { color: #166534; }
.pp-sheet .pp-lo .deficit { color: #b91c1c; }

.pay-box { flex: 0 0 380px; }
.pay-price { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.pay-price span { font-size: .95rem; color: #333; }
.pay-price b { font-size: 1.5rem; font-weight: 700; }
.pay-mail { font-size: .8rem; color: #666; margin: 4px 0 0; }

/* Footer */
.foot { border-top: 1px solid #eee; padding: 24px 16px; margin-top: 32px; }
.foot .wrap { max-width: 1000px; margin: 0 auto; }
.foot .links { font-size: .8rem; display: flex; gap: 16px; }
.foot .links a { color: #666; text-decoration: none; }
.foot .links a:hover { text-decoration: underline; }
/* Responsive */
@media (max-width: 760px) {
  .studio { flex-direction: column-reverse; }
  .studio .panel { flex: none; width: 100%; }
  .studio .preview { position: static; width: 100%; }
  .summary { grid-template-columns: 1fr; }
  .inc-fields { grid-template-columns: 1fr 1fr; }
  .exp-fields { grid-template-columns: 1fr 1fr; }
  .cat-f { grid-column: 1 / -1; }
  .pay-grid { flex-direction: column; }
  .pay-box { flex: none; width: 100%; }
}

@media (min-width: 761px) {
  .inc-row + .inc-row .inc-f span { display: none; }
  .inc-row + .inc-row .row-remove { margin-top: 0; }
  .exp-row + .exp-row .exp-f span { display: none; }
  .exp-row + .exp-row .row-remove { margin-top: 0; }
}
