:root {
  --ink: #14213d;
  --muted: #667085;
  --line: #e5eaf1;
  --soft: #f5f8fc;
  --blue: #0f62fe;
  --blue-dark: #084fc7;
  --green: #14b87a;
  --danger: #d92d20;
  --shadow: 0 18px 50px rgba(16, 35, 70, .10);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f9;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-width: 340px;
  background:
    radial-gradient(circle at 12% 8%, rgba(25, 117, 255, .08), transparent 26rem),
    #eef3f9;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 42px);
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid rgba(220, 228, 239, .9);
  backdrop-filter: blur(12px);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 0; color: inherit; text-align: left; background: transparent; border: 0; cursor: pointer; }
.brand:focus-visible { outline: 3px solid rgba(15, 98, 254, .22); outline-offset: 4px; border-radius: 13px; }
.brand-mark { display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 13px; color: #fff; background: var(--blue); box-shadow: 0 8px 20px rgba(15, 98, 254, .25); }
.brand-mark svg { width: 27px; height: 27px; fill: currentColor; }
.brand-mark .brand-accent { fill: #5ce0aa; }
.brand-copy { min-width: 0; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 15px; letter-spacing: -.2px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.brand-title { display: flex !important; align-items: center; gap: 5px; }
.brand-vietqr-logo { display: block; width: auto; height: 19px; object-fit: contain; }


.web-badge { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px; color: var(--blue); background: #f4f8ff; border: 1px solid #cfe0ff; border-radius: 999px; box-shadow: 0 2px 9px rgba(15, 98, 254, .08); white-space: nowrap; }
.web-badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.web-badge span { font-size: 10px; font-weight: 850; letter-spacing: .06em; }

.view-switch { display: flex; gap: 6px; padding: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; }
.view-switch button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 10px; color: #667085; background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.view-switch button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.view-switch button.active { color: var(--blue); background: #fff; border-color: var(--blue); box-shadow: 0 2px 9px rgba(15, 98, 254, .13); }
.view-switch button span { font-size: 12px; font-weight: 700; }

.workspace { display: grid; gap: 22px; width: min(1080px, calc(100% - 32px)); margin: 26px auto; }
.form-panel, .preview-panel { background: #fff; border: 1px solid rgba(220, 227, 238, .9); border-radius: 20px; box-shadow: var(--shadow); }
.form-panel { padding: 24px; }
.preview-panel { padding: 24px; align-self: start; }
.section-heading, .preview-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .11em; }
h1, h2 { margin: 0; font-size: 21px; line-height: 1.2; letter-spacing: -.45px; }

.icon-button { display: grid; place-items: center; width: 36px; height: 36px; color: #7a8699; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.icon-button:hover { color: var(--danger); border-color: #fecaca; background: #fff5f4; }
.icon-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

#qrForm { display: grid; gap: 16px; }
.field { min-width: 0; }
.field label, #bankLabel { display: block; margin: 0 0 7px; color: #344054; font-size: 12px; font-weight: 700; }
.field label span, #bankLabel span { color: var(--danger); }
.field input:not([type="radio"]):not([type="checkbox"]) { width: 100%; height: 45px; padding: 0 13px; color: var(--ink); background: #fff; border: 1px solid #d9e1ec; border-radius: 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: #98a2b3; }
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15, 98, 254, .11); }
.field input.invalid, .bank-trigger.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(217, 45, 32, .08); }
.hint, .error-text { min-height: 14px; margin: 5px 2px 0; font-size: 10px; line-height: 1.4; }
.hint { color: #8a94a6; }
.error-text { color: var(--danger); }
.hint-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hint-row span { color: #98a2b3; font-size: 10px; }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 56px !important; }
.input-suffix span { position: absolute; top: 50%; right: 13px; color: #667085; font-size: 11px; font-weight: 800; transform: translateY(-50%); }

.bank-combobox { position: relative; }
.bank-trigger { display: flex; align-items: center; width: 100%; min-height: 54px; padding: 7px 11px; text-align: left; background: #fff; border: 1px solid #d9e1ec; border-radius: 11px; cursor: pointer; }
.logo-frame { display: grid; place-items: center; flex: 0 0 38px; width: 38px; height: 38px; padding: 4px; overflow: hidden; background: #fff; border: 1px solid #eef1f5; border-radius: 9px; }
.logo-frame img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.bank-selected-copy { flex: 1; min-width: 0; margin-left: 10px; }
.bank-selected-copy strong, .bank-selected-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-selected-copy strong { color: #24324a; font-size: 13px; }
.bank-selected-copy small { margin-top: 3px; color: #8a94a6; font-size: 10px; }
.chevron { width: 18px; height: 18px; fill: none; stroke: #98a2b3; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transition: transform .15s; }
.bank-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.bank-menu { position: absolute; z-index: 50; top: calc(100% - 10px); left: 0; width: 100%; min-width: 290px; padding: 9px; background: #fff; border: 1px solid #dce3ec; border-radius: 13px; box-shadow: 0 16px 34px rgba(16, 35, 70, .18); }
.bank-search-wrap { position: relative; margin-bottom: 7px; }
.bank-search-wrap svg { position: absolute; top: 50%; left: 11px; width: 16px; height: 16px; fill: none; stroke: #98a2b3; stroke-width: 1.8; transform: translateY(-50%); }
.bank-search-wrap input { width: 100%; height: 39px; padding: 0 12px 0 38px !important; text-align: left; border: 1px solid #dce3ec; border-radius: 9px; outline: none; }
.bank-search-wrap input:focus { border-color: var(--blue); }
.bank-list { max-height: 300px; overflow: auto; overscroll-behavior: contain; }
.bank-option { display: flex; align-items: center; width: 100%; min-height: 48px; padding: 6px 8px; text-align: left; background: transparent; border: 0; border-radius: 9px; cursor: pointer; }
.bank-option:hover, .bank-option[aria-selected="true"] { background: #f0f6ff; }
.bank-option[aria-selected="true"] { box-shadow: inset 0 0 0 1px rgba(15, 98, 254, .2); }
.bank-option .logo-frame { flex-basis: 34px; width: 34px; height: 34px; }
.bank-option strong, .bank-option small { display: block; }
.bank-option strong { color: #27364f; font-size: 12px; }
.bank-option small { margin-top: 2px; color: #8993a4; font-size: 9px; }
.bank-option-copy { flex: 1; min-width: 0; margin-left: 9px; }
.bank-option .organization-pill { flex: 0 0 auto; margin-left: 8px; padding: 4px 7px; color: #4b5e79; font-size: 8px; font-weight: 800; background: #f1f5f9; border: 1px solid #dbe3ed; border-radius: 99px; white-space: nowrap; }
.bank-option .organization-pill.wallet { color: #8d185c; background: #fff0f8; border-color: #f7cde4; }
.bank-option .organization-pill.mobile_money { color: #087a66; background: #ebfbf6; border-color: #bcebdd; }
.bank-option .organization-pill.finance_company { color: #9a4d05; background: #fff7e9; border-color: #f5d69d; }
.bank-option .organization-pill.digital_bank { color: #1756a9; background: #edf5ff; border-color: #c7ddfb; }
.no-results { padding: 25px 10px; color: #8a94a6; font-size: 11px; text-align: center; }

.advanced { overflow: visible; background: #f8fafc; border: 1px solid #e8edf4; border-radius: 11px; }
.advanced summary { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px; color: #526071; font-size: 11px; font-weight: 750; list-style: none; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .15s; }
.advanced[open] summary svg { transform: rotate(180deg); }
.advanced-body { display: grid; gap: 15px; padding: 2px 13px 14px; }
.template-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.template-picker.three-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.template-picker label { margin: 0; cursor: pointer; }
.template-picker input { position: absolute; opacity: 0; }
.template-picker label span { display: block; padding: 10px; color: #667085; background: #fff; border: 1px solid #dce3ec; border-radius: 9px; }
.template-picker label strong, .template-picker label small { display: block; }
.template-picker label strong { color: #344054; font-size: 11px; }
.template-picker label small { margin-top: 3px; color: #98a2b3; font-size: 9px; }
.template-picker input:checked + span { color: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 2px rgba(15, 98, 254, .09); }
.template-picker input:checked + span strong { color: var(--blue); }
.hint-row.count-only { justify-content: flex-end; }

.primary-button, .secondary-button, .download-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 45px; padding: 0 15px; font-weight: 800; border-radius: 10px; cursor: pointer; transition: transform .1s, background .15s, opacity .15s; }
.primary-button { width: 100%; margin-top: 2px; color: #fff; background: var(--blue); border: 1px solid var(--blue); box-shadow: 0 8px 20px rgba(15, 98, 254, .2); }
.primary-button:hover, .download-button:hover { background: var(--blue-dark); }
.primary-button:active, .secondary-button:active, .download-button:active { transform: translateY(1px); }
.primary-button svg, .secondary-button svg, .download-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.primary-button svg rect { stroke-width: 1.7; }

.size-pill { padding: 6px 9px; color: #64748b; font-size: 9px; font-weight: 800; background: #f3f6fa; border: 1px solid #e4e9f0; border-radius: 99px; white-space: nowrap; }
.canvas-stage { display: grid; place-items: center; min-height: 420px; padding: 18px; overflow: hidden; background: #f5f8fc; border: 1px dashed #ccd7e5; border-radius: 15px; }
.empty-state { color: #8490a3; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 74px; height: 74px; margin: 0 auto 15px; color: #9aa8bb; background: #fff; border: 1px solid #e2e8f0; border-radius: 20px; box-shadow: 0 8px 22px rgba(28, 52, 85, .07); }
.empty-state svg { width: 42px; height: 42px; fill: currentColor; }
.empty-state svg path:last-child { fill: #d8e3f1; }
.empty-state strong { display: block; color: #536174; font-size: 13px; }
.empty-state p { margin: 7px 0 0; font-size: 10px; line-height: 1.6; }
#qrCanvas { display: block; width: min(100%, 380px); height: auto; background: #fff; border-radius: 8px; box-shadow: 0 12px 30px rgba(18, 38, 68, .13); }

.result-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.valid-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; color: #087a50; background: #eafbf4; border: 1px solid #b7efd8; border-radius: 99px; }
.valid-badge span { width: 6px; height: 6px; background: #13b879; border-radius: 50%; box-shadow: 0 0 0 3px rgba(19, 184, 121, .12); }
.valid-badge strong { font-size: 8px; letter-spacing: .04em; }
.result-meta code { max-width: 100%; padding: 5px 7px; overflow: hidden; color: #586579; font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; background: #f4f6f9; border-radius: 6px; }

.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.secondary-button, .download-button { min-height: 42px; font-size: 11px; }
.secondary-button { color: #3e4b5f; background: #fff; border: 1px solid #d8e0ea; }
.secondary-button:hover { color: var(--blue); border-color: #9fc0ff; }
.download-button { color: #fff; background: var(--blue); border: 1px solid var(--blue); }
.secondary-button:disabled, .download-button:disabled { color: #9ba5b5; background: #edf1f5; border-color: #e1e6ed; cursor: not-allowed; opacity: .72; }
.privacy-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 0; color: #8a94a6; font-size: 9px; }
.privacy-note svg { width: 14px; height: 14px; fill: none; stroke: #56a98a; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.app-credit { width: min(1080px, calc(100% - 32px)); margin: -5px auto 26px; color: #7b8799; font-size: 10px; line-height: 1.55; text-align: center; }
.app-credit p { margin: 3px 0; }
.app-credit strong { color: #4e5b6e; font-weight: 800; }

.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; max-width: min(320px, calc(100vw - 36px)); padding: 10px 13px; color: #fff; font-size: 11px; font-weight: 700; background: #1e293b; border-radius: 9px; box-shadow: 0 10px 24px rgba(15, 23, 42, .25); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (min-width: 880px) {
  .workspace { grid-template-columns: minmax(350px, .88fr) minmax(430px, 1.12fr); }
  .preview-panel { position: sticky; top: 98px; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px 13px; }
  .brand small { display: none; }
  .web-badge { width: 34px; justify-content: center; padding: 0; }
  .web-badge span { display: none; }
  .view-switch button { width: 34px; justify-content: center; padding: 0; }
  .view-switch button span { display: none; }
  .workspace { width: calc(100% - 18px); margin: 12px auto; gap: 12px; }
  .form-panel, .preview-panel { padding: 17px; border-radius: 15px; }
  .form-panel { box-shadow: 0 10px 30px rgba(16, 35, 70, .08); }
  .preview-panel { box-shadow: 0 10px 30px rgba(16, 35, 70, .08); }
  .canvas-stage { min-height: 330px; padding: 11px; }
  .action-row { grid-template-columns: 1fr; }
  .bank-menu { position: fixed; top: 82px; left: 10px; width: calc(100vw - 20px); max-height: calc(100vh - 100px); }
  .bank-list { max-height: calc(100vh - 170px); }
  .template-picker.three-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
