:root {
  --bg: #0a0d14;
  --panel: #121724;
  --panel-2: #1a2030;
  --panel-3: #222a3d;
  --border: #2a3347;
  --text: #e7eaf2;
  --muted: #8a92a6;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --success: #36c08d;
  --warn: #f0b84a;
  --danger: #ef5b6b;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16203a 0%, var(--bg) 55%) var(--bg);
  background-repeat: no-repeat;
  background-attachment: fixed; /* pin to viewport — no repeat, no scroll */
  background-size: cover;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; backdrop-filter: blur(8px);
  background: rgba(10, 13, 20, 0.75); z-index: 10;
}
.brand { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; cursor: pointer; }
.brand-mark {
  font-weight: 800; letter-spacing: 0.14em; font-size: 18px;
  background: linear-gradient(90deg, #fff, #b9c8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }
.session { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.session .who { color: var(--muted); }
.session .who b { color: var(--text); }

.app { max-width: 1140px; margin: 0 auto; padding: 24px; }
.footer { text-align: center; color: var(--muted); font-size: 11px; padding: 24px; }

/* Layout helpers */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 320px 1fr; align-items: start; }
@media (max-width: 820px) { .cols-2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, #0f1420 100%);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; }
.card h3 { margin: 0 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.muted { color: var(--muted); }
.hr { height: 1px; background: var(--border); margin: 14px 0; border: 0; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; }

/* Forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text);
  font-family: var(--sans); font-size: 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Buttons */
button {
  padding: 9px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--panel-3); color: var(--text); cursor: pointer; font-size: 13px;
  font-family: var(--sans); transition: transform 0.05s ease, background 0.15s ease;
}
button:hover { background: #2a3450; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #07101f; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.success { background: var(--success); border-color: var(--success); color: #04140d; font-weight: 600; }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.ghost { background: transparent; color: var(--accent-2); border-color: var(--accent-2); }
button.ghost:hover { background: rgba(91,140,255,0.08); }
button.small { padding: 6px 10px; font-size: 12px; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--panel-2); }

/* Status pills */
.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 600; letter-spacing: 0.03em; border: 1px solid transparent; white-space: nowrap;
}
.pill.gray { background: #232a3a; color: #aab3c6; }
.pill.blue { background: rgba(91,140,255,0.15); color: var(--accent-2); border-color: rgba(91,140,255,0.3); }
.pill.amber { background: rgba(240,184,74,0.13); color: var(--warn); border-color: rgba(240,184,74,0.3); }
.pill.green { background: rgba(54,192,141,0.14); color: var(--success); border-color: rgba(54,192,141,0.3); }
.pill.red { background: rgba(239,91,107,0.14); color: var(--danger); border-color: rgba(239,91,107,0.3); }

/* Key/value */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* Timeline / events */
.events { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow: auto; }
.events li { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12px; }
.events .t { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-3); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 10px; font-size: 13px; opacity: 0;
  transition: opacity 0.2s ease; pointer-events: none; max-width: 90%; z-index: 50;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--success); }

.demo-logins { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge-role { font-size: 10px; padding: 2px 7px; border-radius: 6px; background: var(--panel-3); color: var(--muted); }
.fee-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.fee-line.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 600; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

/* Email-verification banner */
.banner-warn {
  border-color: var(--warn);
  background: linear-gradient(0deg, rgba(240, 184, 74, 0.08), rgba(240, 184, 74, 0.08)), var(--panel);
  color: var(--text);
}

/* Inline interface notices (legal) */
.notice-inline {
  font-size: 11.5px; line-height: 1.5; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; margin: 6px 0;
}
.notice-inline a { color: var(--accent-2); text-decoration: none; }
.notice-inline a:hover { text-decoration: underline; }

/* Footer legal links */
.footer-sep { margin: 0 6px; color: var(--border); }
.footer a { color: var(--muted); text-decoration: none; margin: 0 6px; }
.footer a:hover { color: var(--accent-2); text-decoration: underline; }

/* Report-content control on the deal detail card */
.report-row { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); text-align: right; }

/* Header navigation + user chip (link into the personal cabinet) */
.session { display: flex; align-items: center; gap: 8px; }
.nav-link {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 6px 10px; border-radius: 8px; cursor: pointer; font: inherit;
}
.nav-link:hover { color: var(--text); background: var(--panel-2); }
.nav-link.active { color: var(--text); border-color: var(--border); background: var(--panel-2); }
.user-chip {
  display: flex; align-items: center; gap: 8px; cursor: pointer; font: inherit;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 4px 10px 4px 4px; border-radius: 999px;
}
.user-chip:hover { border-color: var(--accent); }
.user-chip.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91, 140, 255, .15); }
.user-chip .who { font-size: 13px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0d14;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }

/* Personal cabinet */
.account { max-width: 980px; margin: 0 auto; }
.account-head { display: flex; align-items: center; gap: 18px; }
.account-id { flex: 1; }
.account-id h1 { margin: 0; font-size: 22px; }
.button-link {
  display: inline-block; text-decoration: none; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 7px 12px; border-radius: 8px;
}
.button-link:hover { border-color: var(--accent); color: var(--accent-2); }

/* Listings management */
.listing-row { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); }
.listing-cover { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); flex: 0 0 auto; background: var(--panel-3); }
.listing-main { flex: 1; min-width: 0; }
.qr-slot { margin-top: 10px; }
.qr-img { width: 160px; height: 160px; background: #fff; padding: 8px; border-radius: 10px; }

/* Management states */
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }
.is-archived { opacity: 0.62; }

/* ===========================================================================
   UX refinements: cabinet bar, QR scanner, square covers, hero, responsive
   =========================================================================== */
:root { --radius-sm: 10px; --radius-pill: 999px; }

/* Cabinet action bar (ADD NEW / SCAN QR / SELLING / BUYING) */
.cabinet-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.cbar-btn {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 700; letter-spacing: .04em;
  cursor: pointer; padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
}
.cbar-btn:hover { border-color: var(--accent); }
.cbar-btn .ic { font-size: 15px; line-height: 1; }
.cbar-seg-group { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.cbar-seg {
  font: inherit; font-weight: 700; letter-spacing: .04em; cursor: pointer;
  padding: 10px 18px; background: transparent; border: 0; color: var(--muted);
}
.cbar-seg + .cbar-seg { border-left: 1px solid var(--border); }
.cbar-seg.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #0a0d14; }

/* Square covers everywhere (1:1) */
.listing-cover { width: 72px; height: 72px; }
.cover-prev { margin-top: 8px; width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

/* QR scanner overlay */
.scan-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(6,9,15,.86); display: flex; align-items: center; justify-content: center; padding: 20px; }
.scan-box { position: relative; width: min(92vw, 420px); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px; text-align: center; }
.scan-video { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 12px; background: #000; }
.scan-frame { position: absolute; inset: 14px 14px 64px; border: 2px solid var(--accent); border-radius: 12px; pointer-events: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.0); }
.scan-hint { color: var(--muted); font-size: 13px; margin: 10px 0 8px; }

/* Logged-out home: hero + tariffs */
.home { display: grid; grid-template-columns: 1.3fr .9fr; gap: 32px; max-width: 1040px; margin: 4vh auto; align-items: start; }
.hero-mark { font-weight: 800; letter-spacing: .22em; color: var(--muted); font-size: 13px; }
.hero-title { font-size: 38px; line-height: 1.1; margin: 10px 0 14px; letter-spacing: -.01em; }
.hero-sub { color: #cfd6e6; font-size: 16px; line-height: 1.65; max-width: 56ch; }
.hero-tagline { color: var(--muted); font-size: 14px; line-height: 1.6; max-width: 56ch; margin-top: 10px; }
.hero-howto { font-weight: 700; font-size: 13px; letter-spacing: .04em; color: var(--text); margin-top: 18px; }
.hero-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0 22px; color: var(--muted); font-size: 13px; }
.hero-steps span b { color: var(--accent-2); margin-right: 4px; }
.hero-steps i { color: var(--border); font-style: normal; }
.hero-media { margin: 18px 0 6px; }
.hero-media img { width: 100%; max-height: 360px; object-fit: cover; border-radius: 20px; box-shadow: 0 25px 55px rgba(4, 13, 38, .18); }
.vip-hero { margin: 18px 0 6px; }
.vip-hero img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 18px; border: 1px solid rgba(255,255,255,.09); }
.tariffs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.t-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 14px; }
.t-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(91,140,255,.2); }
.t-top { display: flex; justify-content: space-between; align-items: baseline; }
.t-name { font-weight: 700; }
.t-rate { font-size: 22px; font-weight: 800; color: var(--accent-2); }
.t-min { color: var(--muted); font-size: 12px; margin-top: 2px; }
.t-blurb { color: #cfd6e6; font-size: 13px; line-height: 1.5; margin-top: 8px; }
.hero-foot { margin-top: 18px; font-size: 12px; }

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .home { grid-template-columns: 1fr; }
  .hero-title { font-size: 30px; }
}
@media (max-width: 760px) {
  .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .session { flex-wrap: wrap; }
  .cbar-seg-group { margin-left: 0; }
  .tariffs-grid { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .grid[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .account-head { flex-wrap: wrap; }
}
@media (max-width: 460px) {
  .hero-title { font-size: 26px; }
  .cabinet-bar { gap: 8px; }
  .cbar-btn { padding: 9px 12px; font-size: 13px; }
  .listing-row { flex-direction: column; }
  .listing-cover { width: 100%; height: auto; aspect-ratio: 1/1; max-width: 180px; }
}

/* Avatars rendered as <img> share the .avatar sizing */
img.avatar { object-fit: cover; background: var(--panel-3); }

/* Perfect responsive: stack inline 2-col grids, fluid account head, no overflow */
@media (max-width: 760px) {
  .app { padding: 14px 14px 30px; }
  .grid[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }
  .field-row { grid-template-columns: 1fr !important; }
  .account-head { gap: 12px; }
  .account-id h1 { font-size: 19px; }
  .cabinet-bar { gap: 8px; }
  .cbar-seg-group { width: 100%; }
  .cbar-seg { flex: 1; text-align: center; }
}
@media (max-width: 460px) {
  .cbar-btn { flex: 1; justify-content: center; }
  .section-title { flex-wrap: wrap; gap: 8px; }
}

/* Prevent grid/flex children from expanding to intrinsic content width
   (e.g. a nowrap table) and overflowing on mobile. */
.grid > *, .stack, .stack > *, .card, .listing-main, .account-id { min-width: 0; }
.card table { max-width: 100%; }

/* Full-screen QR scanner */
.scan-overlay { position: fixed; inset: 0; z-index: 60; background: #000; display: block; padding: 0; }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.scan-x { position: absolute; top: 14px; right: 14px; z-index: 2; width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3); background: rgba(0,0,0,.5); color: #fff; font-size: 18px; cursor: pointer; }
.scan-reticle { position: absolute; top: 50%; left: 50%; width: min(70vw, 300px); height: min(70vw, 300px);
  transform: translate(-50%, -56%); border: 3px solid rgba(255,255,255,.85); border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-overlay.ok .scan-reticle { border-color: var(--success); }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; align-items: center;
  background: linear-gradient(0deg, rgba(0,0,0,.72), transparent); }
.scan-status { color: #fff; font-size: 14px; text-align: center; }
.scan-open { width: min(92vw, 420px); padding: 16px; font-weight: 800; letter-spacing: .06em; }
.scan-open:disabled { opacity: .4; cursor: not-allowed; }

/* Purchase cards (BUYING) */
.buy-card { display: flex; gap: 14px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-2); cursor: pointer; }
.buy-card:hover { border-color: var(--accent); }
.buy-cover-wrap { width: 84px; height: 84px; flex: 0 0 auto; border-radius: 10px; overflow: hidden; background: var(--panel-3); }
.buy-cover { width: 100%; height: 100%; object-fit: cover; display: block; }
.buy-main { flex: 1; min-width: 0; }

/* Checkout (buy) auth screen */
.checkout-prod { display: flex; gap: 16px; align-items: center; }
.checkout-info { min-width: 0; }

/* QR preview modal (cabinet) */
.modal-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(6,9,15,.78); display: flex; align-items: center; justify-content: center; padding: 20px; }
.qr-modal { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 18px; width: min(92vw, 360px); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); cursor: pointer; }
.qr-modal-img { width: 100%; max-width: 300px; border-radius: 12px; }

/* OTP confirmation modal */
.otp-modal { gap: 10px; }
.otp-head { text-align: center; }
.otp-title { font-weight: 700; font-size: 16px; }
.otp-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.otp-input { width: 100%; text-align: center; font-size: 30px; font-weight: 800; letter-spacing: .5em;
  padding: 12px 10px 12px 18px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); }
.otp-input:focus { outline: none; border-color: var(--accent); }
.otp-msg { font-size: 12px; color: var(--muted); min-height: 14px; text-align: center; }
.otp-msg.err { color: var(--danger, #ff6b6b); }
.otp-dev { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; text-align: center; }

/* Upload progress bar */
.upload-bar { height: 8px; background: var(--panel-3); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.upload-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s ease; }

/* VIP form block + badges */
.vip-block { border: 1px solid var(--accent); border-radius: 10px; padding: 14px 12px 4px; margin: 10px 0; position: relative; }
.vip-tag { position: absolute; top: -10px; left: 12px; background: var(--accent); color: #07101f; font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .06em; }
.plan-badge { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 999px; letter-spacing: .05em; }
.plan-badge.vip { background: linear-gradient(135deg, #f0b84a, #e89a2c); color: #1a1205; }
.plan-badge.free { background: var(--panel-3); color: var(--muted); }
.usage-bar { height: 6px; background: var(--panel-3); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.usage-bar span { display: block; height: 100%; background: var(--accent); }

/* Super-admin settings forms */
.settings-grid { display: grid; gap: 14px; }
.set-row { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: center; }
.set-row input { max-width: 100%; }
.wallet-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; margin-bottom: 6px; }
.tariff-edit { display: grid; grid-template-columns: 90px repeat(4, 1fr); gap: 8px; align-items: center; font-size: 12px; }
.tariff-edit input { padding: 6px 8px; }
