.cg { padding: 22px 0 10px; }
.cg [hidden] { display: none !important; }
.cg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.12fr); gap: 22px; align-items: start; }
.cg label, .cg .cg-lbl { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cg label small { font-weight: 600; }
.cg input, .cg select, .cg textarea { width: 100%; font: inherit; font-size: 15px; border: 1px solid #ddd6cb; border-radius: 10px; padding: 8px 10px; background: #fff; color: var(--text); min-height: 42px; box-sizing: border-box; }
.cg textarea { min-height: 64px; resize: vertical; }
.cg input:focus, .cg select:focus, .cg textarea:focus { outline: 3px solid rgba(245, 158, 11, .35); border-color: var(--gold); }
.cg input[type=color] { padding: 3px; height: 42px; }
.cg input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: #d97706; }
.cg input[type=range] { padding: 0; min-height: 30px; border: 0; accent-color: #d97706; }
.cg-sec { border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin-bottom: 12px; padding: 0 16px; }
.cg-sec > summary { cursor: pointer; font-weight: 800; padding: 14px 0; display: flex; align-items: center; gap: 10px; list-style: none; }
.cg-sec > summary::-webkit-details-marker { display: none; }
.cg-sec > summary .cg-n { width: 24px; height: 24px; border-radius: 50%; background: var(--gold); color: #1f1d1a; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.cg-sec > summary .cg-s { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cg-sec > summary::after { content: "▾"; color: var(--muted); }
.cg-sec[open] > summary::after { content: "▴"; }
.cg-in { padding: 0 0 16px; }
.cg-g2, .cg-g3, .cg-g4 { display: grid; gap: 10px; }
.cg-g2 { grid-template-columns: 1fr 1fr; }
.cg-g3 { grid-template-columns: repeat(3, 1fr); }
.cg-g4 { grid-template-columns: 2fr 1fr 0.8fr 1.2fr; }
.cg-g2 > *, .cg-g3 > *, .cg-g4 > * { min-width: 0; }
.cg-span2 { grid-column: span 2; }
.cg-end { display: flex; align-items: flex-end; }
.cg-mt { margin-top: 10px; }
.cg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cg-hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.cg-link { font: inherit; font-size: 13px; border: 0; background: none; color: var(--gold-text); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.cg-check { display: flex !important; align-items: center; gap: 8px; font-size: 14px !important; color: var(--text) !important; font-weight: 600 !important; cursor: pointer; margin: 0; }
.cg-up { cursor: pointer; margin: 0 !important; color: #1f1d1a !important; font-size: 13.5px !important; }
.cg-warn { margin-top: 10px; background: #fff7ed; border: 1px solid #fed7aa; color: #7c2d12; border-radius: 10px; padding: 8px 10px; font-size: 13px; font-weight: 700; }
.cg-more { font-size: 12.5px; color: var(--muted); }

/* list table */
.cg-paste { margin-top: 10px; }
.cg-paste textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; margin-bottom: 8px; }
.cg-tw { margin-top: 12px; overflow: auto; max-height: 320px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.cg-tw table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.cg-tw th { position: sticky; top: 0; background: #fffbeb; text-align: left; padding: 6px 8px; border-bottom: 1px solid #f3e3b5; font-size: 12px; white-space: nowrap; z-index: 1; }
.cg-tw th span { display: block; min-width: 60px; outline: none; border-radius: 4px; }
.cg-tw th span:focus { background: #fff; box-shadow: 0 0 0 2px #f59e0b; }
.cg-tw th small { display: block; color: #b45309; font-weight: 800; font-size: 11px; }
.cg-tw th small.cg-free { color: #a8a094; font-weight: 600; }
.cg-tw td { padding: 6px 8px; border-bottom: 1px solid #f0ece5; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.cg-tw td[contenteditable]:focus { outline: 2px solid #f59e0b; background: #fff; white-space: normal; }
.cg-tw .cg-rn { color: #a8a094; width: 28px; text-align: right; font-size: 11.5px; background: #faf8f4; }
.cg-tw tr.cg-bad td { background: #fef2f2; }
.cg-x { font: inherit; border: 0; background: none; color: #b8b0a4; cursor: pointer; padding: 2px 6px; font-size: 13px; }
.cg-x:hover { color: #b42318; }
.cg-map { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cg-map label { font-size: 12px; margin: 0; color: var(--text); }
.cg-map select { font-size: 13.5px; min-height: 36px; padding: 5px 8px; margin-top: 3px; }

/* designs */
.cg-designs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.cg-designs button { border: 2px solid var(--line); border-radius: 12px; background: #fff; padding: 6px 4px; cursor: pointer; font: inherit; font-weight: 800; font-size: 11.5px; text-align: center; min-width: 0; color: var(--text); }
.cg-designs button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 6px 16px rgba(245, 158, 11, .25); }
.cg-designs i { display: block; height: 40px; width: 88%; border-radius: 3px; margin: 0 auto 5px; border: 1px solid #e5e7eb; position: relative; overflow: hidden; }
.cg-i1 { background: #fffaf0; box-shadow: inset 0 0 0 3px #fffaf0, inset 0 0 0 5px #b8892b; }
.cg-i1::after { content: ""; position: absolute; left: 30%; right: 30%; top: 45%; height: 4px; background: #7a5410; border-radius: 2px; }
.cg-i2 { background: linear-gradient(100deg, #12213b 0 32%, #f59e0b 32% 37%, #fff 37%); }
.cg-i3 { background: #fbfaf6; box-shadow: inset 0 0 0 3px #1d3a6b, inset 0 0 0 5px #fbfaf6, inset 0 0 0 6px #1d3a6b; }
.cg-i3::after { content: ""; position: absolute; left: 44%; bottom: 5px; width: 10px; height: 10px; border-radius: 50%; background: #c0392b; }
.cg-i4 { background: #fff; }
.cg-i4::before { content: ""; position: absolute; left: 12%; top: 0; width: 26%; height: 3px; background: #0f766e; }
.cg-i4::after { content: ""; position: absolute; left: 12%; top: 45%; width: 52%; height: 4px; background: #1f1d1a; border-radius: 2px; }
.cg-i5 { background: linear-gradient(90deg, #ef476f 0 20%, #ffd166 20% 40%, #06d6a0 40% 60%, #118ab2 60% 80%, #8338ec 80%) top / 100% 4px no-repeat, #fffdf5; box-shadow: inset 0 0 0 3px #fffdf5, inset 0 0 0 4px #ffb703; }
.cg-i6 { background: repeating-linear-gradient(135deg, #f1ece3 0 5px, #e6dfd3 5px 10px); }
.cg-i6::after { content: "+"; position: absolute; inset: 0; display: grid; place-items: center; font-style: normal; font-weight: 800; color: #8a8278; }
.cg-presets, .cg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cg-presets button, .cg-chips button { font: inherit; font-size: 13px; font-weight: 700; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.cg-presets button[aria-pressed="true"] { background: #1f1d1a; color: #fff; border-color: #1f1d1a; }
.cg-chips { margin-top: 8px; }
.cg-chips button { font-size: 12px; padding: 4px 10px; background: #fffbeb; border-color: #f3e3b5; color: #92400e; }

/* uploads */
.cg-upl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cg-pv { width: 42px; height: 42px; border: 1px dashed #cfc6b8; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #a9a196; font-size: 11px; flex: none; overflow: hidden; background: #fff; }
.cg-pv.cg-pvw { width: 110px; }
.cg-pv img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
.cg .cg-upbtn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border: 1px solid #ddd6cb; border-radius: 10px; background: var(--soft); font-weight: 700; font-size: 14px; color: var(--text); cursor: pointer; margin: 0; white-space: nowrap; font-family: inherit; }
.cg-sig { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.cg-sig > b { display: block; margin-bottom: 6px; font-size: 14px; }
.cg-sig > b small { color: var(--muted); font-weight: 600; }
.cg-own { margin-top: 12px; border: 1px solid #f3e3b5; background: #fffbeb; border-radius: 12px; padding: 12px; }
.cg-field { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px; margin: 8px 0; }
.cg-field.cg-on { border-color: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, .3); }
.cg-field .cg-g2 { grid-template-columns: 1fr auto; }
.cg-field .cg-g4 { margin-top: 6px; }
.cg-field input, .cg-field select { min-height: 36px; font-size: 13.5px; padding: 5px 8px; }

/* preview */
.cg-side { position: sticky; top: 12px; }
.cg-pvbox { background: #e9e6e0; border-radius: 16px; padding: 14px; }
.cg-pvbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 12.5px; font-weight: 800; color: var(--muted); letter-spacing: .4px; }
.cg-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cg-nav span { flex: 1; text-align: center; font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cg-nav button { font: inherit; font-size: 20px; width: 38px; height: 34px; border-radius: 9px; border: 1px solid #d6cfc3; background: #fff; cursor: pointer; color: var(--text); }
.cg-nav button:disabled { opacity: .35; cursor: default; }
.cg-pv-wrap { border-radius: 4px; overflow: hidden; box-shadow: 0 8px 22px rgba(0, 0, 0, .12); background: #fff; }
.cg-pv-wrap canvas { display: block; outline: none; touch-action: none; }
.cg-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cg-acts .btn { padding: 10px 14px; font-size: 14px; }
.cg-acts .btn.soft { color: var(--text); }
.cg-prog { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.cg-bar { height: 8px; background: #d9d3c8; border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.cg-bar div { height: 100%; width: 0; background: #f59e0b; transition: width .2s; }
.cg-msg { min-height: 20px; font-size: 13px; font-weight: 700; color: #15803d; margin-top: 8px; }
.cg-msg.cg-err { color: #b42318; }
.cg-msg.cg-stay { color: var(--muted); }
.cg-store { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.cg-store button { font: inherit; font-size: 12.5px; border: 0; background: none; color: var(--gold-text); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
body.cg-busy [data-dl] { opacity: .5; pointer-events: none; }

/* signature pad */
.cg-pad { position: fixed; inset: 0; background: rgba(31, 29, 26, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.cg-padbox { background: #fff; border-radius: 16px; padding: 16px; width: 100%; max-width: 640px; }
.cg-padbox canvas { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px dashed #cfc6b8; border-radius: 10px; margin: 10px 0; touch-action: none; background: #fffefb; }

@media (max-width: 980px) {
  .cg-grid { grid-template-columns: minmax(0, 1fr); }
  .cg-side { position: static; order: -1; }
}
@media (max-width: 560px) {
  .cg-designs { grid-template-columns: repeat(3, 1fr); }
  .cg-g3 { grid-template-columns: 1fr 1fr; }
  .cg-span2 { grid-column: auto; }
  .cg-g4 { grid-template-columns: 1fr 1fr; }
  .cg-acts .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .cg-acts .btn.gold { flex-basis: 100%; }
}
