:root {
  --bg: #0b0d12; --bg2: #11141b; --card: #151923; --line: #232838; --text: #e8eaf0; --muted: #8b93a7;
  --accent: #6d5efc; --accent2: #22d3ee; --ok: #22c55e; --warn: #f59e0b; --err: #ef4444; --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); text-decoration: none; cursor: pointer; font-weight: 600; font-size: 14px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #3a4160; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8b5cf6); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.buy { background: linear-gradient(135deg, #f59e0b, #f97316); border-color: transparent; color: #111; }
.btn.danger { color: #fca5a5; border-color: #4b1d1d; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.topnav { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); background: rgba(11,13,18,.8); border-bottom: 1px solid var(--line); }
.topnav .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; text-decoration: none; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent2)); }

.hero { padding: 72px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 56px); margin: 0 0 14px; letter-spacing: -.02em; }
.hero h1 span { background: linear-gradient(135deg, #a78bfa, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 auto 28px; }
.search { display: flex; max-width: 560px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px 4px 4px 16px; }
.search input { flex: 1; background: none; border: 0; outline: 0; font-size: 15px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 26px 0 32px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.active, .chip:hover { color: var(--text); border-color: var(--accent); background: rgba(109,94,252,.12); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 24px; padding-bottom: 80px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  transition: transform .2s, border-color .2s, box-shadow .2s; text-decoration: none; }
.card:hover { transform: translateY(-4px); border-color: #3b3f74; box-shadow: 0 20px 40px -20px rgba(109,94,252,.45); }
.thumb { position: relative; aspect-ratio: 16/10; background: var(--bg2); overflow: hidden; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb iframe { width: 400%; height: 400%; transform: scale(.25); transform-origin: 0 0; border: 0; pointer-events: none; background: #fff; }
.thumb .badge-featured { position: absolute; top: 12px; left: 12px; }
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body h3 { margin: 0; font-size: 18px; }
.card-body p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.price { font-weight: 800; font-size: 17px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 11px; padding: 3px 8px; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em;
  background: rgba(109,94,252,.18); color: #c4b5fd; display: inline-block; }
.badge.ok { background: rgba(34,197,94,.15); color: #86efac; }
.badge.warn { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge.err { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge.gray { background: #1f2433; color: var(--muted); }
.badge-featured { background: linear-gradient(135deg,#f59e0b,#f97316); color: #111; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; grid-column: 1/-1; }
.empty-page { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 8px; color: var(--muted); }
.empty-page h1 { font-size: 72px; margin: 0; color: var(--text); }

/* ---------- viewer ---------- */
.viewer { display: flex; flex-direction: column; height: 100vh; padding: 10px; gap: 10px; background: radial-gradient(circle at top, #1a1640, var(--bg) 60%); }
.viewer-bar { display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.viewer-bar .title { flex: 1; min-width: 0; }
.viewer-bar .title strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-bar .title small { color: var(--muted); }
.viewer-frame { position: relative; flex: 1; border: 3px solid transparent; border-radius: 14px; overflow: hidden;
  background: linear-gradient(#fff,#fff) padding-box, linear-gradient(135deg, var(--accent), var(--accent2), #f59e0b) border-box; }
.viewer-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.devices { display: flex; gap: 4px; }
.devices button { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; color: var(--muted); }
.devices button.active { color: var(--text); border-color: var(--accent); }
.viewer-frame.tablet, .viewer-frame.mobile { align-self: center; }
.viewer-frame.tablet { width: 820px; max-width: 100%; }
.viewer-frame.mobile { width: 400px; max-width: 100%; }
@media (max-width: 720px) { .devices, .hide-sm { display: none !important; } .viewer-bar { gap: 8px; } }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: none; place-items: center; z-index: 100; padding: 20px; backdrop-filter: blur(4px); }
.modal-backdrop.open { display: grid; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 26px; }
.modal.wide { width: min(860px, 100%); }
.modal h2 { margin: 0 0 6px; }
.modal .sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: #c3c8d6; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, textarea.input, select.input { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 110px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
.inline { display: flex; gap: 8px; align-items: stretch; }
.suffix { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #0d1016; color: var(--muted); font-size: 13px; white-space: nowrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.alert.err { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid #4b1d1d; }
.alert.ok { background: rgba(34,197,94,.12); color: #86efac; border: 1px solid #14532d; }
.alert.info { background: rgba(34,211,238,.08); color: #a5f3fc; border: 1px solid #164e63; }
.status-line { font-size: 13px; min-height: 18px; }
.status-line.ok { color: #86efac; } .status-line.err { color: #fca5a5; } .status-line.info { color: var(--muted); }
.progress { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; display: none; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .2s; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.dropzone.drag, .dropzone:hover { border-color: var(--accent); color: var(--text); }
.dropzone strong { color: var(--text); }

/* ---------- login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 30% 20%, #1d1747, var(--bg) 55%); }
.auth-card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; }
.auth-card h1 { margin: 14px 0 4px; font-size: 24px; }
.auth-card p { color: var(--muted); margin: 0 0 22px; }

/* ---------- admin ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 20px; gap: 16px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 26px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat b { display: block; font-size: 26px; } .stat span { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { background: none; border: 0; padding: 12px 16px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 60px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg2); }
tr:last-child td { border-bottom: 0; }
td .mini-thumb { width: 64px; height: 40px; border-radius: 6px; object-fit: cover; object-position: top; background: var(--bg2); display: block; }
td .muted, .muted { color: var(--muted); font-size: 12px; }
td.actions { white-space: nowrap; text-align: right; }
td.msg { max-width: 320px; white-space: pre-wrap; color: #c3c8d6; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--card); border: 1px solid var(--line); padding: 12px 18px; border-radius: 10px; z-index: 200;
  transform: translateY(120px); transition: .25s; } .toast.show { transform: none; }
.hidden { display: none !important; }
footer.site-foot { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

/* website loading progress */
.load-bar { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 3; background: rgba(109,94,252,.12); transition: opacity .4s; }
.load-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2), #f59e0b);
  box-shadow: 0 0 12px rgba(34,211,238,.6); transition: width .25s ease-out; border-radius: 0 4px 4px 0; }
.load-overlay { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; background: var(--bg2); transition: opacity .45s, visibility .45s; }
.load-bar.done, .load-overlay.done { opacity: 0; visibility: hidden; pointer-events: none; }
.load-card { display: grid; justify-items: center; gap: 10px; width: min(320px, 80%); text-align: center; }
.load-ring { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent2); animation: load-spin .8s linear infinite; }
.load-pct { font-size: 34px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.load-text { color: var(--muted); font-size: 14px; }
.load-track { width: 100%; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.load-track span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .25s ease-out; }
@keyframes load-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .load-ring { animation: none; } .load-bar span, .load-track span { transition: none; } }
