:root {
    --bg: #ffffff; --fg: #1f2328; --muted: #6b7280; --line: #e5e7eb; --soft: #f6f7f9;
    --brand: #1a73e8; --ok: #0f9d58; --warn: #b45309; --err: #d93025;
}
@media (prefers-color-scheme: dark) {
    :root { --bg: #14161a; --fg: #e8eaed; --muted: #9aa0a6; --line: #2d3036; --soft: #1d2025; --brand: #8ab4f8; --ok: #5bd18b; --warn: #fbbf24; --err: #f28b82; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: Tahoma, "Segoe UI", Vazirmatn, sans-serif; font-size: 16px; line-height: 1.7; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.4; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }

.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1rem; gap: 1rem; }
.topbar nav { display: flex; gap: 1rem; align-items: center; font-size: .95rem; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 1rem 3rem; }

.hero { min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1.5rem; }
.logo { font-size: 2.6rem; font-weight: 700; letter-spacing: -1px; direction: ltr; }
.logo b { color: var(--brand); font-weight: 700; }
.searchbox { width: min(560px, 100%); display: flex; gap: .5rem; flex-direction: column; }
.searchbox input { width: 100%; padding: .9rem 1.2rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font-size: 1.15rem; text-align: center; letter-spacing: 2px; direction: ltr; outline: none; }
.searchbox input:focus { box-shadow: 0 1px 8px rgba(0,0,0,.18); border-color: transparent; }
.hint { color: var(--muted); font-size: .9rem; }

.btn { cursor: pointer; border: 1px solid var(--line); background: var(--soft); color: var(--fg); padding: .55rem 1.2rem; border-radius: 8px; font: inherit; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--err); }
.btn.sm { padding: .25rem .7rem; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.center { justify-content: center; }

.card { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--bg); }
.card.result { text-align: right; width: min(560px, 100%); }
.product { display: flex; gap: 1rem; align-items: flex-start; }
.product img, .thumb { width: 110px; height: 110px; object-fit: cover; border-radius: 10px; background: var(--soft); flex: none; }
.thumb { display: grid; place-items: center; color: var(--muted); font-size: .8rem; }
.product .meta { flex: 1; min-width: 0; }
.badge { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .82rem; border: 1px solid currentColor; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); } .muted { color: var(--muted); }

.grid { display: grid; gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.field label { font-size: .9rem; color: var(--muted); }
.field input, .field textarea, .field select { padding: .6rem .8rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
.field input[dir=ltr] { text-align: left; }
.formcard { max-width: 420px; margin: 4vh auto 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 1rem 0; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: .5rem 1rem; cursor: pointer; font: inherit; color: var(--muted); }
.tabs button.active { color: var(--brand); border-color: var(--brand); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: right; padding: .5rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tablewrap { overflow-x: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; }
.stat { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }
.stat b { display: block; font-size: 1.4rem; }
.mono { font-family: Consolas, monospace; direction: ltr; unicode-bidi: embed; }
.note { padding: .6rem .8rem; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); margin: .6rem 0; }

#blazor-error-ui { background: #fff3cd; color: #333; bottom: 0; display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; left: .75rem; top: .5rem; }

@media (max-width: 520px) { .product { flex-direction: column; } .logo { font-size: 2.1rem; } }

/* ---- merged code input + button ---- */
.codebar { width: min(560px, 100%); display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); transition: box-shadow .15s; }
.codebar:focus-within { box-shadow: 0 1px 10px rgba(0,0,0,.2); border-color: transparent; }
.codeinput { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--fg); padding: .95rem 1.2rem; font: 600 1.25rem Consolas, "Courier New", monospace; letter-spacing: 2px; text-align: center; direction: ltr; }
.codebtn { border: 0; background: var(--brand); color: #fff; font: inherit; font-weight: 600; padding: 0 1.6rem; cursor: pointer; white-space: nowrap; }
.codebtn:hover { filter: brightness(1.08); }
.codebtn:disabled { opacity: .6; cursor: default; }
@media (max-width: 420px) { .codeinput { font-size: 1.05rem; letter-spacing: 1px; padding: .85rem .6rem; } .codebtn { padding: 0 1rem; } }

/* ---- swal-style dialog ---- */
.swal-backdrop { position: fixed; inset: 0; background: rgba(15,18,24,.55); display: grid; place-items: center; z-index: 2000; padding: 1rem; animation: swalFade .15s ease-out; }
.swal { width: min(440px, 100%); max-height: 92vh; overflow: auto; background: var(--bg); color: var(--fg); border-radius: 18px; padding: 1.6rem 1.4rem 1.2rem; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); animation: swalPop .28s cubic-bezier(.2,1.3,.4,1); }
.swal-title { font-size: 1.3rem; margin: .4rem 0 .3rem; }
.swal-text { margin: 0 0 .6rem; color: var(--muted); }
.swal-body { text-align: right; border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .8rem; }
.swal-actions { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.swal-actions .btn { min-width: 110px; text-decoration: none; }
.swal-icon { width: 78px; height: 78px; margin: 0 auto .4rem; }
.swal-icon svg { width: 100%; height: 100%; }
.swal-circle { fill: none; stroke-width: 3; stroke-dasharray: 151; stroke-dashoffset: 151; animation: swalDraw .55s .05s ease-out forwards; }
.swal-mark { fill: none; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: swalDraw .4s .45s ease-out forwards; }
.swal-mark-fill { stroke-width: 0; opacity: 0; animation: swalFade .3s .45s forwards; }
.swal-dot { opacity: 0; animation: swalFade .2s .75s forwards; }
.swal-success .swal-circle, .swal-success .swal-mark { stroke: var(--ok); }
.swal-error .swal-circle, .swal-error .swal-mark { stroke: var(--err); }
.swal-warning .swal-circle, .swal-warning .swal-mark { stroke: var(--warn); } .swal-warning .swal-dot { fill: var(--warn); }
.swal-lock .swal-circle, .swal-lock .swal-mark { stroke: var(--warn); } .swal-lock .swal-mark-fill { fill: var(--warn); }
@keyframes swalDraw { to { stroke-dashoffset: 0; } }
@keyframes swalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes swalPop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.settings-group { margin-bottom: 1.2rem; }
.settings-group .field { max-width: 460px; }
