/* Document editor (templates/documents/*) */
.doc-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; padding: 10px 0 8px; }
.doc-head h1 { margin: 0 0 4px; font-size: clamp(1.4rem, 3.6vw, 1.9rem); }
.doc-head p { margin: 0; color: var(--muted); }
.doc-head .quota { min-width: 260px; }
.doc-types { color: var(--muted); margin-bottom: 14px; }

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.doc-form { display: flex; flex-direction: column; gap: 12px; }
.doc-sec summary { cursor: pointer; font-weight: 600; }
.doc-sec[open] summary { margin-bottom: 12px; }
.doc-h { font-size: 1rem; margin: 0 0 10px; }
.doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.doc-grid .wide { grid-column: 1 / -1; }
.doc-grid .field { margin-bottom: 10px; }
.doc-brand { border-top: 1px dashed var(--line); padding: 10px 0; margin-bottom: 6px; font-size: .9rem; }

.doc-item { display: grid; grid-template-columns: 22px minmax(0, 3fr) 64px 70px 90px 72px 88px auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.doc-item input { padding: 7px 8px; font-size: .88rem; }
.doc-item .n { font-size: .8rem; color: var(--muted); text-align: center; }
.doc-item .amt { font-size: .88rem; text-align: right; font-variant-numeric: tabular-nums; }
.doc-item .tools { display: flex; gap: 2px; }
.doc-item .tools button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; font-size: .85rem; border-radius: 6px; }
.doc-item .tools button:hover { background: var(--line); color: var(--text); }

.doc-colors { display: flex; gap: 8px; }
.doc-colors button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.doc-colors button.active { box-shadow: 0 0 0 2px var(--c); }

.doc-side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 10px; }
.doc-actions { display: flex; flex-direction: column; gap: 8px; }
.doc-msg.ok { color: var(--ok); } .doc-msg.bad { color: var(--bad); }

/* Live preview: an A4 sheet, always light like paper */
.doc-preview-wrap { border-radius: var(--radius); background: #e9e6e1; padding: 12px; max-height: 70vh; overflow: auto; }
.doc-preview { --accent: #e8453c; position: relative; background: #fff; color: #1d1b19; aspect-ratio: 210 / 297; min-height: 0;
  padding: 6% 6.5%; font-size: 9px; line-height: 1.45; box-shadow: 0 2px 10px rgb(0 0 0 / .12); overflow: hidden; }
.doc-preview table { border-collapse: collapse; width: 100%; }
.pv-top { display: flex; justify-content: space-between; gap: 12px; }
.pv-shop { font-size: 12px; display: block; }
.pv-logo { max-width: 90px; max-height: 44px; display: block; margin-bottom: 4px; }
.pv-small { color: #666; font-size: 8px; }
.pv-ph { color: #aaa; }
.pv-title { text-align: right; min-width: 40%; }
.pv-title > b { color: var(--accent); font-size: 17px; display: block; line-height: 1.2; }
.pv-title > span { color: #888; font-size: 8px; }
.pv-title td { padding: 1px 0; } .pv-title td:first-child { color: #666; text-align: left; } .pv-title td:last-child { text-align: right; }
.pv-cust { margin: 12px 0; padding: 7px 9px; background: #faf9f7; border: 1px solid #ddd8d0; display: flex; flex-direction: column; }
.pv-items th { background: var(--accent); color: #fff; font-weight: 700; padding: 4px; text-align: right; }
.pv-items td { padding: 4px; border-bottom: 1px solid #e8e4dd; text-align: right; vertical-align: top; }
.pv-items .l { text-align: left; } .pv-items td:first-child, .pv-items th:first-child { text-align: center; width: 18px; }
.pv-bottom { display: flex; gap: 10px; margin-top: 10px; align-items: flex-start; }
.pv-words { flex: 1; } .pv-words > b { color: var(--accent); display: block; margin-bottom: 6px; }
.pv-qr { width: 54px; height: 54px; border: 1px dashed #bbb; display: grid; place-items: center; text-align: center; font-size: 7px; color: #888; }
.pv-sums { width: 44% !important; } .pv-sums td { padding: 2px 0; } .pv-sums td:last-child { text-align: right; }
.pv-signs { display: flex; justify-content: space-around; text-align: center; margin-top: 24px; color: #444; }
.pv-credit { position: absolute; left: 6.5%; bottom: 2.5%; font-size: 7px; color: #999; }
.pv-mark { position: absolute; inset: 0; display: grid; place-items: center; font-size: 64px; font-weight: 700; color: rgb(0 0 0 / .06);
  transform: rotate(-30deg); pointer-events: none; }

.doc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.doc-card { display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.doc-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.doc-card b { font-size: 1.05rem; } .doc-card span { color: var(--muted); font-size: .88rem; }

@media (max-width: 980px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; }
  .doc-preview-wrap { max-height: none; }
}
@media (max-width: 640px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr); }
  .doc-item { grid-template-columns: 22px repeat(4, minmax(0, 1fr)); padding: 8px 0; border-bottom: 1px solid var(--line); }
  .doc-item .desc { grid-column: 2 / -1; }
  .doc-item .amt { grid-column: 2 / 4; text-align: left; }
  .doc-item .tools { grid-column: 4 / -1; justify-content: flex-end; }
}
.doc-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft);
  color: var(--accent); margin-bottom: 4px; }
.doc-ico .icon { width: 24px; height: 24px; }
