:root {
  --bg: #f3f5f9; --surface: #fff; --ink: #142033; --muted: #5b6678; --line: #dde2ea;
  --brand: #1d4ed8; --brand-ink: #fff; --brand-soft: #e7eefe;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --wa: #128c4a; --radius: 12px; --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 2px 8px rgb(16 24 40 / .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h2 { font-size: 17px; margin: 0 0 12px; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.r { text-align: right; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
/* Menu bawah */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgb(16 24 40 / .06);
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
}
.bottom-nav button {
  flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none;
  padding: 6px 8px; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px;
}
.bottom-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav button:hover { background: var(--bg); }
.bottom-nav button.on { color: var(--brand); background: var(--brand-soft); }

main { max-width: 1320px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.page { max-width: 980px; margin: 0 auto; display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

/* ---------- Form ---------- */
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label small { font-weight: 400; }
input, select, textarea {
  width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 14px 0 0; padding: 12px 0 0; display: grid; gap: 10px; }
legend { font-weight: 700; padding: 0 6px 0 0; font-size: 14px; }
.form { display: grid; gap: 10px; }
.grid2, .grid3 { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.with-btn { display: flex; gap: 6px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.head-row h2 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: #b8c2d2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--bad); }
.btn.add { justify-self: start; border-style: dashed; }
.link { border: 0; background: none; color: var(--brand); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
.icon-btn { border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; width: 32px; height: 36px; }
.icon-btn:hover { background: var(--bad-soft); color: var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.hint { max-width: 1320px; margin: 0 auto 12px; background: var(--brand-soft); color: #1e3a8a; border-radius: 10px; padding: 10px 14px; }

/* ---------- Editor ---------- */
.editor { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; }
.item-head, .item-row { display: grid; gap: 6px; grid-template-columns: minmax(0, 1fr) 64px 76px 120px 110px 32px; align-items: center; }
.item-head { font-size: 12px; font-weight: 700; color: var(--muted); }
#itemRows { display: grid; gap: 6px; }
.amt { text-align: right; font-weight: 600; font-size: 14px; white-space: nowrap; }
.totals { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; background: var(--brand-soft); border-radius: 10px; }
.totals small { display: block; color: var(--muted); }
.totals strong { font-size: 22px; }
.preview { position: sticky; top: 76px; }
.preview-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.preview-scroll { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.s-lunas { background: var(--ok-soft); color: var(--ok); }
.s-dp { background: var(--warn-soft); color: var(--warn); }
.s-belum-lunas { background: var(--bad-soft); color: var(--bad); }

/* ---------- Riwayat ---------- */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat small { color: var(--muted); display: block; }
.stat strong { font-size: 20px; }
.stat.warn strong { color: var(--bad); }
.toolbar { display: grid; gap: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 99px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
#list { display: grid; gap: 10px; }
.inv {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
  display: grid; gap: 8px 16px; grid-template-columns: minmax(0, 1fr) auto;
}
.inv-main { display: grid; gap: 1px; min-width: 0; }
.inv-main > * { overflow-wrap: anywhere; }
.inv-amt { display: grid; justify-items: end; gap: 3px; align-content: start; }
.inv-amt small { color: var(--bad); font-weight: 600; }
.inv-act { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.late { color: var(--bad); font-weight: 700; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Pengaturan ---------- */
.logo-box { display: grid; place-items: center; height: 120px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); }
.logo-box img { max-height: 100px; max-width: 80%; object-fit: contain; }
.actions.wrap { flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 60;
  background: #142033; color: #fff; padding: 11px 18px; border-radius: 10px; transition: .2s; max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

/* ---------- Nota (kertas) ---------- */
.nota {
  background: #fff; color: #111; font: 13px/1.45 system-ui, "Segoe UI", Arial, sans-serif;
  padding: 28px; min-width: 560px; border-radius: var(--radius);
}
.nota table { width: 100%; border-collapse: collapse; }
.nota td, .nota th { padding: 4px 6px; vertical-align: top; text-align: left; }
.nota .r { text-align: right; white-space: nowrap; }
.nota .c { text-align: center; white-space: nowrap; }
.n-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid #111; padding-bottom: 12px; }
.n-brand { display: flex; gap: 12px; align-items: center; }
.n-logo { max-height: 64px; max-width: 120px; object-fit: contain; }
.n-store { font-size: 20px; font-weight: 800; }
.n-title { text-align: right; font-size: 20px; font-weight: 800; letter-spacing: .06em; white-space: nowrap; }
.n-title small { display: block; font-size: 11px; font-weight: 600; color: #666; letter-spacing: .25em; }
.n-meta { display: flex; justify-content: space-between; gap: 16px; margin: 14px 0; }
.n-meta table { width: auto; }
.n-meta td { padding: 1px 10px 1px 0; }
.n-to { min-width: 210px; max-width: 320px; border: 1px solid #ccc; border-radius: 6px; padding: 8px 12px; overflow-wrap: anywhere; }
.n-lbl { color: #666; font-size: 11px; }
.n-items thead th { background: #f0f0f0; border-top: 1px solid #999; border-bottom: 1px solid #999; font-size: 12px; }
.n-items tbody td { border-bottom: 1px solid #e3e3e3; }
.n-empty { color: #999; padding: 16px !important; }
.n-sum { display: flex; justify-content: space-between; gap: 20px; margin-top: 12px; }
.n-left { flex: 1; min-width: 0; }
.n-words { display: block; }
.n-note, .n-bank { margin-top: 10px; overflow-wrap: anywhere; }
.n-bank { border-left: 3px solid #1d4ed8; padding-left: 8px; }
.n-totals { width: 270px !important; flex: none; }
.n-total td { font-weight: 800; font-size: 15px; border-top: 2px solid #111; border-bottom: 2px solid #111; }
.n-due td { font-weight: 700; color: #b91c1c; }
.n-stamp {
  display: inline-block; margin: 16px 0 0 20px; transform: rotate(-10deg); border: 3px solid #15803d; color: #15803d;
  font-weight: 900; font-size: 20px; letter-spacing: .15em; padding: 2px 12px; border-radius: 6px; opacity: .6;
}
.n-stamp.dp { border-color: #b45309; color: #b45309; }
.n-stamp.unpaid { border-color: #b91c1c; color: #b91c1c; font-size: 16px; }
.n-sign { display: flex; justify-content: space-between; margin-top: 28px; text-align: center; }
.n-sign > div { width: 210px; display: flex; flex-direction: column; }
.n-sign span { height: 56px; }
.n-foot { margin-top: 18px; text-align: center; color: #555; font-size: 12px; border-top: 1px dashed #bbb; padding-top: 8px; }

/* ---------- Pilihan template ---------- */
.tpl-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.tpl-card {
  display: grid; gap: 6px; padding: 6px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface);
  cursor: pointer; text-align: center; min-width: 0;
}
.tpl-card:hover { border-color: #b8c2d2; }
.tpl-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl-card.on .tpl-name::before { content: "✓ "; }
.tpl-thumb { display: block; height: 104px; overflow: hidden; border-radius: 6px; border: 1px solid var(--line); background: #fff; pointer-events: none; }
.tpl-mini { display: block; zoom: .2; }
.tpl-mini .nota { border-radius: 0; }
.tpl-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Gaya tema nota: lihat css/themes.css ---------- */
/* ---------- Responsif ---------- */
@media (max-width: 1080px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
}
@media (max-width: 640px) {
  main { padding: 12px 12px calc(80px + env(safe-area-inset-bottom)); }
  .grid2, .grid3, .stats { grid-template-columns: minmax(0, 1fr); }
  .item-head { display: none; }
  .item-row {
    grid-template-columns: 56px 70px minmax(0, 1fr) 32px; grid-template-areas: "name name name del" "qty unit price price" "amt amt amt amt";
    padding: 8px; border: 1px solid var(--line); border-radius: 10px;
  }
  .item-row [data-it="name"] { grid-area: name; }
  .item-row [data-it="qty"] { grid-area: qty; }
  .item-row [data-it="unit"] { grid-area: unit; }
  .item-row [data-it="price"] { grid-area: price; }
  .item-row .amt { grid-area: amt; }
  .item-row .icon-btn { grid-area: del; }
  .preview-scroll .nota { zoom: .6; }
  .tpl-picker { gap: 6px; }
  .tpl-thumb { height: 84px; }
  .tpl-mini { zoom: .14; }
  .tpl-name { font-size: 11px; }
  .inv { grid-template-columns: minmax(0, 1fr); }
  .inv-amt { justify-items: start; grid-auto-flow: column; justify-content: start; align-items: center; gap: 8px; }
  .topbar { padding: 8px 12px; }
}

/* ---------- Cetak ---------- */
#printArea { display: none; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; }
  body.printing { background: #fff; }
  #printArea .nota { padding: 0; min-width: 0; border-radius: 0; }
  #printArea.paper-A5 .nota { font-size: 11px; }
  #printArea.paper-A5 .n-store, #printArea.paper-A5 .n-title { font-size: 16px; }
  #printArea.paper-A5 .n-totals { width: 220px !important; }
  #printArea.paper-A5 .n-sign span { height: 40px; }
  .n-items tr, .n-sum, .n-sign { break-inside: avoid; }
  .nota, .nota * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Dashboard (gaya beranda CatatKas) ---------- */
.dash-head h1 { margin: 4px 0 2px; font-size: 30px; letter-spacing: -.01em; }
.dash-head p { margin: 0; color: var(--muted); font-size: 16px; }
.dash .chips { margin-top: 2px; }
.dash-cards { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.d-total { grid-column: 1 / -1; display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 4px 28px; align-items: center; padding: 16px 20px !important; }
.d-tot-info, .d-tot-chart { min-width: 0; }
.d-total .d-chart { height: 64px; }
.d-total .d-chart-cap { margin-top: 0; }
.d-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--c, var(--line)); border-radius: 18px;
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
button.d-card { cursor: pointer; transition: transform .12s, box-shadow .12s; }
button.d-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgb(16 24 40 / .1); }
.d-total { background: linear-gradient(135deg, #0f766e, #115e59); color: #fff; border: 0; justify-content: center; }
.d-label { display: block; font-size: 13px; opacity: .88; }
.d-big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; line-height: 1.15; margin: 4px 0; }
.d-sub { display: block; font-size: 13px; color: rgb(255 255 255 / .82); }
.d-chart-cap { display: flex; justify-content: space-between; gap: 8px; width: 100%; margin-top: 12px; font-size: 12px; font-weight: 600; color: rgb(255 255 255 / .78); }
.d-chart { position: relative; width: 100%; height: 88px; margin: 6px 0 2px;
  background: repeating-linear-gradient(to bottom, transparent 0 21px, rgb(255 255 255 / .12) 21px 22px); }
.d-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.d-line-path { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.d-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff; border: 2px solid #0f766e; box-sizing: border-box; }
.d-dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; background: #fff; opacity: .3; animation: dPulse 2s ease-out infinite; }
@keyframes dPulse { from { transform: scale(.6); opacity: .45; } to { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .d-dot::after { animation: none; } }
.d-peak { position: absolute; width: 6px; height: 6px; margin: -5px 0 0 -5px; border-radius: 50%; background: #0f766e; border: 2px solid #fff; box-sizing: content-box; }
.d-axis { display: flex; justify-content: space-between; width: 100%; font-size: 11px; color: rgb(255 255 255 / .7); }
.d-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12px; font-weight: 600; color: rgb(255 255 255 / .9); }
.d-legend span { display: inline-flex; align-items: center; gap: 5px; }
.d-legend i { width: 9px; height: 9px; border-radius: 3px; }
.r-paid { background: #86efac; } .r-pend { background: #fcd34d; } .r-unpaid { background: #fca5a5; }
.d-tag { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: 13px; font-weight: 800; background: var(--cs); color: var(--c); }
.d-mid { display: block; font-size: 22px; font-weight: 800; margin: 10px 0 6px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.d-line { font-size: 13px; color: var(--muted); }
.d-line.ok { color: #15803d; } .d-line.bad { color: #b91c1c; } .d-line.warn { color: #b45309; }
.d-paid { --c: #15803d; --cs: #dcfce7; }
.d-unpaid { --c: #b91c1c; --cs: #fee2e2; }
.d-pend { --c: #b45309; --cs: #fef3c7; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .link { text-decoration: none; }
.d-list { padding: 4px 0; }
.d-row { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.d-row:last-child { border-bottom: 0; }
.d-row:hover { background: var(--bg); }
.d-row-main { display: grid; min-width: 0; }
.d-row-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-row-main small { color: var(--muted); }
.d-row-amt { display: grid; justify-items: end; gap: 3px; white-space: nowrap; }
.d-list .empty { border: 0; }
@media (max-width: 640px) {
  .dash-head h1 { font-size: 26px; }
  .dash-head p { font-size: 14px; }
  .dash-cards { grid-template-columns: 1fr 1fr; }
  .d-pend { grid-column: 1 / -1; }
  .d-big { font-size: 23px; }
  .d-total { grid-template-columns: minmax(0, 1fr); padding: 14px !important; }
  .d-total .d-chart { height: 56px; }
  .d-tot-chart { margin-top: 8px; }
  .d-mid { font-size: 18px; }
  .d-card { padding: 14px; border-radius: 16px; }
}

/* ---------- Bar template & galeri 100 template ---------- */
.tpl-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.tpl-bar-info { display: grid; min-width: 0; }
.tpl-bar-info small { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.tpl-bar-info b { font-size: 15px; }
.tpl-bar-info span { font-size: 12px; color: var(--muted); }
.tpl-bar-act { display: flex; align-items: center; gap: 4px; }
.tpl-bar-act .icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 36px; }
.tpl-bar-act .icon-btn:hover { background: var(--bg); color: var(--brand); }
body.modal-open { overflow: hidden; }
.tpl-modal { position: fixed; inset: 0; z-index: 80; background: rgb(15 23 42 / .55); display: grid; place-items: center; padding: 16px; }
.tpl-dialog { background: var(--surface); border-radius: 16px; width: min(1180px, 100%); height: min(90vh, 900px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.tpl-dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 8px; }
.tpl-dhead h2 { margin: 0; }
.tpl-dhead small { color: var(--muted); }
.tpl-dhead .icon-btn { font-size: 18px; }
.tpl-tools { padding: 0 16px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.tpl-tools .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
.tpl-tools .chip { white-space: nowrap; }
.tpl-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; padding: 14px 16px 20px; align-content: start; }
.tpl-grid .tpl-card { display: grid; gap: 3px; padding: 6px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; min-width: 0; }
.tpl-grid .tpl-card[hidden] { display: none; }
.tpl-grid .tpl-card:hover { border-color: #b8c2d2; }
.tpl-grid .tpl-card.on { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tpl-grid .tpl-thumb { display: block; height: 200px; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); background: #fff; pointer-events: none; }
.tpl-grid .tpl-mini { display: block; zoom: .27; }
.tpl-grid .tpl-mini .nota { border-radius: 0; }
.tpl-grid .tpl-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-grid .tpl-desc { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-none { padding: 20px; text-align: center; }
@media (max-width: 640px) {
  .tpl-modal { padding: 0; }
  .tpl-dialog { height: 100%; border-radius: 0; }
  .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
  .tpl-grid .tpl-thumb { height: 170px; }
  .tpl-grid .tpl-mini { zoom: .26; }
}
