:root{
  --bg:#f4f2f9;
  --card:#ffffff;
  --text:#1f1d2b;
  --text-rgb:31,29,43;
  --muted:#6d6a7c;

  /* Common surfaces (used to override hardcoded whites in markup) */
  --surface: var(--card);
  --surface2: rgba(var(--text-rgb),0.04);
  --surface3: rgba(var(--text-rgb),0.07);
  --input-bg: var(--surface2);
  --input-text: var(--text);

  /* Panel backgrounds for light themes (overridden by dark themes below) */
  --panel: rgba(255,255,255,.72);
  --panel2: rgba(255,255,255,.58);
  --panel3: rgba(255,255,255,.92);
  --panel4: rgba(248,246,255,.88);

  /* Hero banner gradient colors (can be themed) */
  --hero-a:#3d3b6b;
  --hero-b:#6d58f6;
  --hero-c:#b39ad6;

  --danger:#d52828; --danger-rgb:213,40,40;
  --success:#12a058; --success-rgb:18,160,88;

  --p1:#6b53f5;   /* primary */
  --p1-rgb:107,83,245;
  --p2:#8D41D6;   /* accent */
  --p2-rgb:141,65,214;
  --p3:#AE9CC8;   /* soft */
  --p3-rgb:174,156,200;
  --p4:#4F4C6C;   /* deep */
  --p4-rgb:79,76,108;
  --p5:#72678C;   /* mid */
  --line:#e7e3f2;

  --shadow: 0 10px 30px rgba(32, 24, 55, .10);
  --shadow2: 0 6px 18px rgba(32, 24, 55, .10);
  --r20: 20px;
  --r16: 16px;
  --r12: 12px;

  --max: 1320px;
}



/* =========================
   THEMES (v14)
   Applied by setting <html data-theme="...">
   ========================= */

html[data-theme="light_purple"]{
  /* Light • Purple • Classic — modern palette (fashion look)
     Делает тему заметной на главной: фон — градиент, карточки —... */

  /* Brand accents */
  --p1:#A344E5; --p1-rgb:163,68,229;
  --p2:#7A3EC2; --p2-rgb:122,62,194;
  --p3:#5B2BA8; --p3-rgb:91,43,168;
  --p4:#20124D; --p4-rgb:32,18,77;

  /* Background / surfaces */
  /* smoother vertical transition (no hard band in the middle) */
  --bg:
    radial-gradient(1200px 900px at 15% 10%, rgba(163,68,229,.18), transparent 74%),
    radial-gradient(1100px 800px at 90% 18%, rgba(122,62,194,.12), transparent 76%),
    radial-gradient(900px 700px at 35% 115%, rgba(163,68,229,.10), transparent 70%),
    linear-gradient(180deg,
      #FCFBFF 0%,
      #F8F4FF 28%,
      #F2EDFF 52%,
      #ECE4FF 76%,
      #E9E0FF 100%);
  --panel: rgba(255,255,255,.92);
  --panel2: rgba(250,248,255,.88);
  --panel3: rgba(255,255,255,.98);
  --panel4: rgba(248,245,255,.98);

  /* Typography / lines */
  --text:#20124D;
  --muted:#4d3f78;
  --line: rgba(163,68,229,.18);
  --chip: rgba(163,68,229,.12);

  /* Shadows */
  --shadow: 0 10px 24px rgba(32,18,77,0.10);
  --shadow2: 0 22px 70px rgba(32,18,77,0.14);

  /* Hero gradient */
  --hero-a:#F7F0FF;
  --hero-b:#EDE2FF;
  --hero-c:#FFFFFF;
}

html[data-theme="light_green"]{
  /* Soft off-white background to avoid "white on white" */
  --bg:#f4fff8;
  --panel: rgba(255,255,255,.86);
  --panel2: rgba(255,255,255,.72);
  --panel3: rgba(255,255,255,.98);
  --panel4: rgba(248,255,250,.98);
  --p1:#2ecc71; --p1-rgb:46,204,113;
  --p2:#1f9d55; --p2-rgb:31,157,85;
  --p3:#b9e6c8; --p3-rgb:185,230,200;
  --p4:#1f3d2a; --p4-rgb:31,61,42;
  --hero-a:#1f3d2a;
  --hero-b:#2ecc71;
  --hero-c:#b9e6c8;
}

html[data-theme="light_blue"]{
  /* Soft off-white background to avoid "white on white" */
  --bg:#f3f8ff;
  --panel: rgba(255,255,255,.86);
  --panel2: rgba(255,255,255,.72);
  --panel3: rgba(255,255,255,.98);
  --panel4: rgba(248,252,255,.98);
  --p1:#2d8cff; --p1-rgb:45,140,255;
  --p2:#1b60c9; --p2-rgb:27,96,201;
  --p3:#b8d7ff; --p3-rgb:184,215,255;
  --p4:#1f3350; --p4-rgb:31,51,80;
  --hero-a:#1f3350;
  --hero-b:#2d8cff;
  --hero-c:#b8d7ff;
}

html[data-theme="light_purple_glass"]{
  /* Light • Purple • Glass — modern palette (more "glass", less "white sheet") */
  --p1:#A344E5; --p1-rgb:163,68,229;
  --p2:#7A3EC2; --p2-rgb:122,62,194;
  --p3:#5B2BA8; --p3-rgb:91,43,168;
  --p4:#20124D; --p4-rgb:32,18,77;

  --text:#20124D; --text-rgb:32,18,77;
  --muted:#4d3f78;

  --bg: radial-gradient(1200px 700px at 18% 10%, rgba(163,68,229,.22), transparent 60%),
        radial-gradient(900px 600px at 92% 18%, rgba(122,62,194,.18), transparent 55%),
        linear-gradient(180deg, #FBFAFF 0%, #F0EBFF 55%, #FBF7FF 100%);

  /* glass layers */
  --panel: rgba(255,255,255,.52);
  --panel2: rgba(255,255,255,.36);
  --panel3: rgba(255,255,255,.62);
  --panel4: rgba(246,243,255,.70);

  --line: rgba(163,68,229,.22);
  --chip: rgba(163,68,229,.16);
  --shadow: 0 14px 42px rgba(32,18,77,0.18);
  --shadow2: 0 26px 80px rgba(32,18,77,0.22);

  --hero-a:#F7F0FF;
  --hero-b:#EDE2FF;
  --hero-c:#FFFFFF;
}

html[data-theme="light_green_glass"]{
  /* White + glass (Profile style) */
  --bg:#f4fff8;
  --panel: rgba(var(--text-rgb),0.04);
  --panel2: rgba(var(--text-rgb),0.06);
  --panel3: rgba(var(--text-rgb),0.04);
  --panel4: rgba(var(--text-rgb),0.06);
  --line: rgba(var(--p1-rgb),0.22);
  --shadow: 0 14px 42px rgba(0,0,0,0.22);
  --shadow2: 0 10px 26px rgba(36,28,74,0.14);
  --p1:#2ecc71; --p1-rgb:46,204,113;
  --p2:#1f9d55; --p2-rgb:31,157,85;
  --p3:#b9e6c8; --p3-rgb:185,230,200;
  --p4:#1f3d2a; --p4-rgb:31,61,42;
  --hero-a:#1f3d2a;
  --hero-b:#2ecc71;
  --hero-c:#b9e6c8;
}

html[data-theme="light_blue_glass"]{
  /* White + glass (Profile style) */
  --bg:#f3f8ff;
  --panel: rgba(var(--text-rgb),0.04);
  --panel2: rgba(var(--text-rgb),0.06);
  --panel3: rgba(var(--text-rgb),0.04);
  --panel4: rgba(var(--text-rgb),0.06);
  --line: rgba(var(--p1-rgb),0.22);
  --shadow: 0 14px 42px rgba(0,0,0,0.22);
  --shadow2: 0 10px 26px rgba(36,28,74,0.14);
  --p1:#2d8cff; --p1-rgb:45,140,255;
  --p2:#1b60c9; --p2-rgb:27,96,201;
  --p3:#b8d7ff; --p3-rgb:184,215,255;
  --p4:#1f3350; --p4-rgb:31,51,80;
  --hero-a:#1f3350;
  --hero-b:#2d8cff;
  --hero-c:#b8d7ff;
}

/* Stronger separation on light themes (more shadow + slightly darker borders) */
html[data-theme^="light_"]{
  /* Slightly stronger borders + softer but deeper shadows on white themes */
  --line: rgba(var(--text-rgb),.14);
  --shadow: 0 20px 56px rgba(32,24,55,.14);
  --shadow2: 0 12px 30px rgba(32,24,55,.12);
  --shadow3: 0 6px 16px rgba(32,24,55,.10);
}

html[data-theme="dark_purple"]{
  --bg:#0f0b1a;
  --card:#141126;
  --text:#f2efff; --text-rgb:242,239,255;
  --muted:#b2accb;
  --line:rgba(255,255,255,.10);
  --shadow:0 14px 50px rgba(0,0,0,.55);
  --shadow2:0 10px 30px rgba(0,0,0,.45);
  --p1:#6b53f5; --p1-rgb:107,83,245;
  --p2:#8D41D6; --p2-rgb:141,65,214;
  --p3:#AE9CC8; --p3-rgb:174,156,200;
  --p4:#D9D1D4; --p4-rgb:217,209,212;
  --p5:#72678C;

  --panel: rgba(20,18,35,.78);
  --panel2: rgba(20,18,35,.70);
  --panel3: rgba(20,18,35,.86);
  --panel4: rgba(20,18,35,.72);
  --hero-a:#140b2e;
  --hero-b:#6b53f5;
  --hero-c:#2a1b4e;
}

html[data-theme="dark_green"]{
  --bg:#07130c;
  --card:#0e1f14;
  --text:#e9fff3; --text-rgb:233,255,243;
  --muted:#a6d4b6;
  --line:rgba(255,255,255,.10);
  --shadow:0 14px 50px rgba(0,0,0,.60);
  --shadow2:0 10px 30px rgba(0,0,0,.50);
  --p1:#2ecc71; --p1-rgb:46,204,113;
  --p2:#1f9d55; --p2-rgb:31,157,85;
  --p3:#b9e6c8; --p3-rgb:185,230,200;
  --p4:#e6fff0; --p4-rgb:230,255,240;
  --p5:#1f3d2a;
  --panel: rgba(6,26,16,.80);
  --panel2: rgba(6,26,16,.72);
  --panel3: rgba(6,26,16,.88);
  --panel4: rgba(6,26,16,.74);
  --hero-a:#061a10;
  --hero-b:#2ecc71;
  --hero-c:#0e3a22;
}

html[data-theme="dark_blue"]{
  --bg:#07111e;
  --card:#0d1b2d;
  --text:#ecf4ff; --text-rgb:236,244,255;
  --muted:#a9c2e6;
  --line:rgba(255,255,255,.10);
  --shadow:0 14px 50px rgba(0,0,0,.60);
  --shadow2:0 10px 30px rgba(0,0,0,.50);
  --p1:#2d8cff; --p1-rgb:45,140,255;
  --p2:#1b60c9; --p2-rgb:27,96,201;
  --p3:#b8d7ff; --p3-rgb:184,215,255;
  --p4:#eaf3ff; --p4-rgb:234,243,255;
  --p5:#1f3350;
  --panel: rgba(6,20,41,.80);
  --panel2: rgba(6,20,41,.72);
  --panel3: rgba(6,20,41,.88);
  --panel4: rgba(6,20,41,.74);
  --hero-a:#061429;
  --hero-b:#2d8cff;
  --hero-c:#0d2a4b;
}
/* =========================
   ADMIN: Topups status pills + mobile cards in modal (Cart/History)
   ========================= */

.status-badge{
  position:static;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:6px 10px;
  border-radius:999px;
  font-weight:900;
  font-size:12px;
  line-height:1;
  border:1px solid rgba(161,137,255,0.35);
  background:var(--panel2);
  color:var(--text);
  white-space:nowrap;
}
.status-badge.on{
  border-color:rgba(75,205,121,0.35);
  background:rgba(75,205,121,0.14);
}
.status-badge.req{
  border-color:rgba(161,137,255,0.35);
  background:rgba(161,137,255,0.14);
}
.status-badge.off{
  border-color:rgba(255,120,120,0.35);
  background:rgba(255,120,120,0.14);
}

/* Base table helpers (used by admin modal + topups tab) */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.table th,
.table td{
  padding:12px 12px;
  border-bottom:1px solid var(--line);
  vertical-align:middle;
}
.table thead th{
  font-size:12px;
  text-transform:uppercase;
  color:var(--p4);
  letter-spacing:.2px;
  font-weight:900;
  background:rgba(255,255,255,0.55);
}
.table tbody tr:last-child td{ border-bottom:0; }

/* Mobile: turn Cart/History tables inside "Редактировать баланс" modal into card list */
@media (max-width: 640px){
  /* remove horizontal scrolling – show cards instead */
  #pb_cart_wrap,
  #pb_hist_wrap{
    overflow:visible !important;
  }
  #pb_cart_table,
  #pb_hist_table{
    min-width:0 !important;
  }

  .pb-table thead{ display:none; }
  .pb-table,
  .pb-table tbody,
  .pb-table tr,
  .pb-table td{
    display:block;
    width:100%;
  }
  .pb-table tr{
    background:var(--surface);
    border:1px solid var(--line);
    border-radius:14px;
    padding:10px 12px;
    margin:10px 0;
    box-shadow:var(--shadow2);
  }
  .pb-table td{
    border:0;
    padding:8px 0;
    display:flex;
    flex-wrap:wrap;
    align-items:flex-start;
    justify-content:space-between;
    gap:10px 12px;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
  .pb-table td:before{
    content:attr(data-label);
    font-weight:900;
    color:var(--muted);
    text-transform:uppercase;
    font-size:11px;
    letter-spacing:.2px;
    flex:0 0 auto;
    max-width:48%;
  }

  /* Mobile: turn ALL .table (admin lists) into card list, theme-aware */
  .table:not(.pb-table) thead{ display:none !important; }
  .table:not(.pb-table),
  .table:not(.pb-table) tbody,
  .table:not(.pb-table) tr,
  .table:not(.pb-table) td{
    display:block !important;
    width:100% !important;
  }
  .table:not(.pb-table) tr{
    background:var(--surface) !important;
    border:1px solid var(--line) !important;
    border-radius:16px;
    padding:10px 12px;
    margin:10px 0;
    box-shadow:var(--shadow2);
  }
  .table:not(.pb-table) td{
    border:0 !important;
    padding:8px 0 !important;
    display:flex !important;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
  }
  .table:not(.pb-table) td::before{
    content:attr(data-label);
    font-weight:900;
    color:var(--muted);
    text-transform:uppercase;
    font-size:11px;
    letter-spacing:.2px;
    flex:0 0 auto;
    max-width:48%;
  }
  .table:not(.pb-table) td > *{ max-width:62%; }
  /* Long comments should not "push" the card sideways on mobile */
  .pb-table td[data-label="Комментарий"]{
    flex-direction:column;
    align-items:flex-start;
  }
  .pb-table td[data-label="Комментарий"]:before{
    max-width:100%;
  }
  .pb-table td[data-label="Иконка"]{
    justify-content:flex-start;
    gap:10px;
  }
  .pb-table td[data-label="Иконка"]:before{ display:none; }
  .pb-table td img{
    width:44px;
    height:44px;
    border-radius:10px;
  }
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

html[data-theme$="_glass"] body{
  background:
    radial-gradient(1200px 900px at 10% -10%, rgba(var(--p1-rgb),.20), rgba(var(--p1-rgb),0) 60%),
    radial-gradient(1000px 700px at 90% 0%, rgba(var(--p2-rgb),.14), rgba(var(--p2-rgb),0) 55%),
    radial-gradient(900px 700px at 50% 110%, rgba(var(--p1-rgb),.10), rgba(var(--p1-rgb),0) 60%),
    var(--bg);
}

html[data-theme$="_glass"] .card,
html[data-theme$="_glass"] .pill,
html[data-theme$="_glass"] .searchbar,
html[data-theme$="_glass"] .modal,
html[data-theme$="_glass"] .dropdown{
  backdrop-filter: blur(14px);
}


/* Prevent background scroll when any modal/backdrop is open */
body.modal-open{ overflow:hidden; }

a{color:inherit; text-decoration:none}
button,input,textarea,select{font:inherit}
img{max-width:100%; display:block}

.corner-img{
  position: fixed;
  left: 26px;
  top: 26px;
  width: 340px;
  height: auto;
  max-height: 520px;
  object-fit: contain;
  border-radius: 26px;
  box-shadow: var(--shadow);
  z-index: 2;
  pointer-events: none;
}

@media (max-width: 1180px){
  .corner-img{ display:none !important; }
}

.container{max-width:var(--max); margin:0 auto; padding: 18px;}

.top-banner{
  border-radius: 26px;
  overflow:hidden;
  box-shadow: var(--shadow);
  background:
    radial-gradient(1000px 320px at 12% 30%, rgba(var(--p3-rgb), .55), transparent 60%),
    radial-gradient(900px 320px at 86% 64%, rgba(var(--p1-rgb), .35), transparent 60%),
    linear-gradient(135deg, var(--hero-a), var(--hero-b) 55%, var(--hero-c));
  position:relative;
  height: 190px;
}

.top-banner:before{
  content:"";
  position:absolute; inset:0;
  background-image:
    radial-gradient(circle at 15% 30%, rgba(255,255,255,.15) 0 2px, transparent 3px),
    radial-gradient(circle at 25% 55%, rgba(255,255,255,.10) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 35%, rgba(255,255,255,.12) 0 2px, transparent 3px);
  opacity:.9;
}

.banner-inner{
  position:relative;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 18px;
  height:100%;
  padding: 22px 24px;
}

.banner-left{
  display:flex; gap: 18px; align-items:flex-start;
}
.banner-bubble{
  width: 54px; height:54px;
  border-radius: 18px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  display:grid; place-items:center;
  backdrop-filter: blur(6px);
}
.banner-text h1{
  margin:0;
  font-size: 20px;
  line-height: 1.05;
  color:#fff;
  letter-spacing:.3px;
}
.banner-text .bonus{
  margin-top:10px;
  color: rgba(255,255,255,.88);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing:.8px;
  font-size: 12px;
}
.bonus-lines{margin-top:8px; color: rgba(255,255,255,.88); font-weight:700}
.bonus-lines div{margin-top:6px}
.bonus-lines b{color:#fff}
.banner-right{
  display:flex; align-items:center; gap: 18px;
}
.money-stack{
  width: 140px; height:140px;
  border-radius: 28px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 14px 40px rgba(0,0,0,.18);
  position:relative;
  overflow:hidden;
}
.money-stack:before{
  content:"";
  position:absolute; inset:-40px;
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), transparent 55%),
    radial-gradient(circle at 65% 70%, rgba(255,255,255,.18), transparent 60%);
}
.money-stack:after{
  content:"";
  position:absolute; right:-10px; bottom:14px;
  font-weight:900;
  color: rgba(255,255,255,.20);
  letter-spacing:2px;
  transform: rotate(-8deg);
  font-size: 22px;
}

.navbar{
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow2);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 14px;
  gap: 12px;
}

.nav-center{
  flex: 1;
  display:flex;
  justify-content:center;
}

.topup-header{
  padding: 12px 18px;
  font-weight: 900;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(123,97,255,.25);
}

@media (max-width: 760px){
  .nav-center{ justify-content:flex-end; }
  .topup-header{ padding: 10px 14px; font-size: 13px; }
}

.store-logo{
  position:absolute;
  left: 18px; top: 18px;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  object-fit: contain;
  opacity: .95;
  filter: drop-shadow(0 10px 22px rgba(0,0,0,.25));
  pointer-events:none;
}


.nav-left{
  display:flex; align-items:center; gap: 18px;
  min-width: 280px;
}
.brand{
  font-weight: 900;
  letter-spacing:.5px;
}
.nav-link{
  font-weight: 800;
  color: var(--p4);
  padding: 8px 10px;
  border-radius: 12px;
}
.nav-link.active{
  background: rgba(var(--p1-rgb),.12);
  color: var(--p1);
}

.nav-right{
  display:flex; align-items:center; gap: 12px;
}
.balance{
  font-weight:900;
  color: var(--p4);
  white-space:nowrap;
}
.user-pill{
  display:flex; align-items:center; gap:10px;
  padding: 6px 10px;
  border-radius: 14px;
  background: rgba(var(--p1-rgb),.10);
  border: 1px solid rgba(var(--p1-rgb),.22);
}

/* --- Tablet navbar (<=1024px): keep buttons inside tile, move ADMIN to the 2nd row --- */
@media (max-width: 1024px){
  /* Let the right side use remaining space and wrap inside the same navbar row */
  .navbar{
    align-items: flex-start;
  }

  .navbar .nav-left{
    min-width: 0;
  }

  .navbar .nav-right{
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
  }

  /* Force ADMIN to a new line (but keep it aligned right) */
  .navbar #adminBtn{
    flex: 0 1 auto;
    flex-basis: 100%;
    width: max-content;
    margin-left: auto;
  }
}

.avatar{
  width: 30px; height:30px; border-radius: 10px;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  display:grid; place-items:center;
  color:#fff; font-weight:900;
  overflow:hidden;
}
.avatar img{width:100%; height:100%; object-fit:cover}
.btn{
  border:0;
  background: var(--p1);
  color:#fff;
  font-weight:900;
  padding: 10px 12px;
  border-radius: 14px;
  cursor:pointer;
  box-shadow: 0 10px 24px rgba(var(--p1-rgb),.25);
  transition: transform .15s ease, filter .15s ease;
}
.btn:hover{transform: translateY(-1px); filter: brightness(1.05)}
.btn.secondary{
  background: var(--panel2);
  color: var(--p4);
  border: 1px solid var(--line);
  box-shadow: none;
}

.main-grid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
}

.searchbar{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  padding: 10px 12px;
  display:flex;
  align-items:center;
  gap: 10px;
}
.search-icon{
  width: 34px; height:34px;
  border-radius: 12px;
  background: rgba(var(--p1-rgb),.12);
  border: 1px solid rgba(var(--p1-rgb),.18);
  display:grid; place-items:center;
}
.searchbar input{
  width:100%;
  border:0; outline:0;
  background: transparent;
  font-weight:700;
  color: var(--p4);
}

/* White themes: stronger separation for main blocks (search, filters, side panels) */
html[data-theme^="light_"] .searchbar,
html[data-theme^="light_"] .server-filter-card,
html[data-theme^="light_"] .pill,
html[data-theme^="light_"] .select,
html[data-theme^="light_"] .side-card,
html[data-theme^="light_"] .server-item{
  border-color: rgba(var(--text-rgb),0.10);
  box-shadow: var(--shadow2), inset 0 1px 0 rgba(255,255,255,.92);
}

html[data-theme^="light_"] .product-card::before{
  /* Stronger separation on white backgrounds (requested: more shadow + outline) */
  border-color: rgba(var(--text-rgb),0.14);
  box-shadow:
    0 12px 32px rgba(32, 24, 55, .14),
    0 3px 14px rgba(32, 24, 55, .08),
    inset 0 1px 0 rgba(255,255,255,.95);
}

html[data-theme^="light_"] .top-banner{
  outline: 1px solid rgba(var(--text-rgb),0.06);
  outline-offset: -1px;
}

/* Server filter plaque (optional) */
.server-filter-card{
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  padding: 12px 12px;
  text-align: center;
}
.server-filter-head{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
  flex-wrap:wrap;
}
.server-filter-text{
  font-weight: 900;
  color: var(--p4);
  line-height: 1.35;
  max-width: 720px;
  margin: 0 auto;
}
.server-filter-pills{ margin-top: 10px; display:flex; gap: 8px; flex-wrap:wrap; justify-content:center }
.server-filter-pill{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 900;
  color: var(--p4);
  cursor:pointer;
  user-select:none;
}
.server-filter-pill.active{
  border-color: rgba(var(--p1-rgb),.35);
  background: rgba(var(--p1-rgb),.12);
  color: var(--p1);
}
.server-filter-empty{
  margin-top: 14px;
  background: var(--panel);
  border: 1px dashed rgba(var(--p1-rgb),.35);
  border-radius: 18px;
  padding: 18px 14px;
  color: var(--p4);
  font-weight: 900;
  text-align:center;
}

.toolbar{
  margin-top: 12px;
  display:flex; align-items:center; justify-content:space-between; gap: 10px;
  flex-wrap: wrap;
}
.pills{display:flex; gap: 8px; flex-wrap: wrap}
.pill{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 800;
  color: var(--p4);
  cursor:pointer;
  user-select:none;
}
.pill.active{
  border-color: rgba(var(--p1-rgb),.35);
  background: rgba(var(--p1-rgb),.12);
  color: var(--p1);
}
.select{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-weight:800;
  color: var(--p4);
}

.product-grid{
  margin-top: 12px;
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

/* Shared hover lift */
.hover-lift{
  position: relative;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}
@media (hover:hover) and (pointer:fine){
  .hover-lift:hover{
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 18px 50px rgba(0,0,0,.14);
    border-color: rgba(var(--p1-rgb),.32);
  }
  .hover-lift{ cursor: pointer; }
}

/* Drag-handle hint (visual only) */
.card-handle{
  position:absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 26px;
  border-radius: 10px;
  background: rgba(var(--p1-rgb),.08);
  border: 1px solid rgba(var(--p1-rgb),.14);
  opacity: 0;
  transition: opacity 200ms ease;
  pointer-events: none;
}
.card-handle::before{
  content:"";
  position:absolute;
  inset: 6px 6px;
  border-radius: 6px;
  background:
    radial-gradient(circle, rgba(var(--p1-rgb),.65) 40%, transparent 41%) 0 0/6px 6px;
  opacity: .9;
}
@media (hover:hover) and (pointer:fine){
  .hover-lift:hover .card-handle{ opacity: 1; }
}

/* Product cards (reference "ДОЛЖНО БЫТЬ") */
.product-card{
  /* Rounded, "plastic" card like reference (no cut corners) */
  background: transparent;
  border: 0;
  box-shadow: none;

  padding: 16px 14px 18px;
  min-height: 285px;               /* slightly more vertical */
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  position:relative;
  overflow:hidden;

  border-radius: 28px;
}

/* background + border + shadow */
.product-card::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: 28px;
  background: linear-gradient(180deg, var(--panel3), var(--panel4));
  border: 1px solid var(--line);
  box-shadow: var(--shadow2);
  z-index:0;

  transition: box-shadow 220ms ease, border-color 220ms ease;
}

/* soft highlight for a more "plastic" feel */
.product-card::after{
  content:"";
  position:absolute;
  inset:-1px;
  border-radius: 30px;
  background:
    radial-gradient(140px 110px at 24% 10%, rgba(var(--p1-rgb),.10), rgba(var(--p1-rgb),0) 70%),
    radial-gradient(180px 140px at 80% 26%, rgba(255,255,255,.75), rgba(255,255,255,0) 65%);
  opacity:.9;
  pointer-events:none;
  z-index:0;
}

.product-card > *{
  position:relative;
  z-index:1;
}

/* Hover depth */
.product-card.hover-lift:hover::before{
  box-shadow: 0 18px 50px rgba(0,0,0,.14);
  border-color: rgba(var(--p1-rgb),.32);
}
.product-sticker{
  height: 168px;
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  margin-top: 6px;

  border-radius: 24px;
  background: var(--panel4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
}

.product-img{
  width: 138px;
  height: 138px;
  object-fit: contain;
  filter: drop-shadow(0 14px 18px rgba(0,0,0,.12));
}
.product-img-fallback{
  width: 150px;
  height: 150px;
  display:grid;
  place-items:center;
  font-weight: 900;
  color: rgba(var(--p4-rgb),.85);
  letter-spacing: 1px;
}

.product-name{
  margin-top: 2px;
  text-align:center;
  font-size: 14px;
  font-weight: 900;
  color: var(--p4);
  text-transform: uppercase;
  line-height: 1.2;
  min-height: 34px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.product-footer{
  width:100%;
  padding-left: 2px;
  margin-top: auto;
  display:flex;
  align-items:center;
  justify-content:flex-start;
}

.product-price-pill{
  display:flex;
  align-items:center;
  /* More compact (≈ -30%) */
  gap: 6px;
  background: rgba(var(--p1-rgb),.92);
  color:#fff;
  font-weight: 900;
  border-radius: 999px;
  padding: 7px 8px;
  font-size: 12px;
  box-shadow: 0 14px 26px rgba(var(--p1-rgb),.25);
}
.product-price-pill .price-ico{
  width: 13px;
  height: 13px;
  display:grid;
  place-items:center;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 9px;
  line-height: 1;
}

.product-discount{
  position:absolute;
  top: 10px;
  right: 10px;
  background: rgba(var(--p1-rgb),.92);
  color:#fff;
  font-weight: 900;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 12px 26px rgba(var(--p1-rgb),.28);
}

/* =========================
   Product cards: dark themes must be truly dark
   (remove the hardcoded light gradient inside cards)
   ========================= */

html[data-theme="dark_purple"] .product-card::before{
  background: linear-gradient(180deg, rgba(20,18,35,.92), rgba(12,10,22,.98));
  border-color: rgba(255,255,255,.10);
}
html[data-theme="dark_green"] .product-card::before{
  background: linear-gradient(180deg, rgba(6,26,16,.92), rgba(4,14,9,.98));
  border-color: rgba(255,255,255,.10);
}
html[data-theme="dark_blue"] .product-card::before{
  background: linear-gradient(180deg, rgba(6,20,41,.92), rgba(3,9,18,.98));
  border-color: rgba(255,255,255,.10);
}

/* soften the bright white highlight in ::after for dark themes */
html[data-theme^="dark_"] .product-card::after{
  background:
    radial-gradient(160px 120px at 24% 10%, rgba(var(--p1-rgb),.18), rgba(var(--p1-rgb),0) 70%),
    radial-gradient(210px 170px at 80% 26%, rgba(255,255,255,.08), rgba(255,255,255,0) 65%);
  opacity: .85;
}

/* sticker (inner image pad) should also go dark, not "milky" */
html[data-theme^="dark_"] .product-sticker{
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    0 10px 24px rgba(0,0,0,.35);
}

.card{
  background: var(--panel3);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow2);
  overflow:hidden;
  position:relative;
  min-height: 230px;
  display:flex;
  flex-direction:column;
}

.badge{
  position:absolute;
  top: 10px; right: 10px;
  background: rgba(var(--p1-rgb),.90);
  color:#fff;
  font-weight: 900;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(var(--p1-rgb),.28);
}

.thumb{
  padding: 18px 18px 8px;
  display:grid;
  place-items:center;
  height: 130px;
}
.thumb .circle{
  width: 110px; height:110px; border-radius: 18px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.7), rgba(255,255,255,.1) 50%, transparent 70%),
              linear-gradient(135deg, rgba(var(--p3-rgb),.6), rgba(var(--p1-rgb),.35));
  border: 1px solid rgba(var(--p1-rgb),.22);
  display:grid;
  place-items:center;
  overflow:hidden;
}
.thumb img{width:100%; height:100%; object-fit:cover}
.card h3{
  margin: 0;
  padding: 0 16px;
  font-size: 13px;
  letter-spacing:.2px;
  text-transform: uppercase;
  color: var(--p4);
  font-weight: 900;
  min-height: 36px;
  display:flex;
  align-items:center;
}
.card .meta{
  padding: 8px 16px 16px;
  margin-top:auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.price-pill{
  display:flex;
  align-items:baseline;
  justify-content:center;
  gap: 4px;
  background: rgba(var(--p1-rgb),.12);
  border: 1px solid rgba(var(--p1-rgb),.20);
  border-radius: 7px;
  padding: 5px 6px;
  font-weight: 900;
  font-size: 12px;
  color: var(--p4);
  white-space: nowrap;
  box-shadow: 0 10px 20px rgba(var(--p1-rgb),.12);
  min-width: 46px;
}

.price-pill .old{opacity:.55; text-decoration: line-through; font-weight: 800; font-size: 10px}
.price-pill .new{color: var(--p1);}
.smallbtn{
  border:0;
  border-radius: 14px;
  padding: 10px 12px;
  font-weight: 900;
  cursor:pointer;
  background: var(--panel);
  border: 1px solid var(--line);
}
.smallbtn.primary{
  background: var(--p1);
  border-color: rgba(var(--p1-rgb),.30);
  color:#fff;
}

.sidebar{
  position:sticky;
  top: 14px;
  align-self:start;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

/* Social links block (Telegram/VK/Discord buttons) */
#linksWrap{
  display:flex;
  flex-direction:column;
  gap: 14px; /* уменьшено ~на 25% */
}
.side-card{
  background: var(--panel3);
  border: 1px solid rgba(var(--p1-rgb),.12);
  border-radius: 18px;
  /* мягкая фиолетовая тень как в примере */
  box-shadow: var(--shadow2);
  padding: 12px 12px;
  display:flex;
  align-items:center;
  gap: 12px;
  transition: box-shadow .18s ease, border-color .18s ease, transform .15s ease;
}
.side-ico{
  width: 48px; height:48px;
  border-radius: 0;
  background: transparent;
  border: 0;
  color: var(--p1);
  display:grid; place-items:center;
}
.side-ico .side-svg{width:44px;height:44px;display:block;transform-origin:50% 50%}
/* Optical normalization: different glyphs have different internal paddings in their paths.
   These mild scales make all social icons look одинакового размера. */
.side-ico .ico-discord{transform:scale(1.15)}
.side-ico .ico-telegram{transform:scale(0.92)}
.side-ico .ico-vk{transform:scale(0.92)}

.side-title{font-weight: 900; color: var(--p4); margin:0; font-size: 14px}
.side-sub{margin:2px 0 0; color: var(--muted); font-weight: 700; font-size: 12px}

/* Hover: добавить фиолетовую обводку (в дополнение к тени) */
.side-card:hover,
.side-card:focus-visible{
  transform: translateY(-1px);
  border-color: rgba(var(--p1-rgb),.70);
  box-shadow:
    0 12px 26px rgba(var(--p1-rgb),.24),
    0 0 0 2px rgba(var(--p1-rgb),.35);
}

/* Servers monitoring list in sidebar (standalone tiles, no wrapper "window"). */
.server-tiles{
  display:flex;
  flex-direction:column;
  gap: 12px;
}

/* (If server list becomes very long, let the page scroll naturally instead of inner scrollbars.) */

.server-item{
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow2);
  border-radius: 22px;
  padding: 12px 12px 12px;
  display:flex;
  flex-direction:column;
  gap: 10px;
  position:relative;
}

.server-title{
  font-weight: 900;
  color: var(--p4);
  font-size: 13px;
  line-height: 1.2;
}

.server-progress{
  height: 10px;
  border-radius: 999px;
  background: rgba(var(--p4-rgb),.10);
  overflow:hidden;
  border: 1px solid rgba(var(--p4-rgb),.10);
}
.server-progress > div{
  height:100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--p1), var(--p2));
}

.server-bottom{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.server-pill{
  background: rgba(var(--p1-rgb),.92);
  color:#fff;
  font-weight: 900;
  border-radius: 999px;
  padding: 8px 10px;
  min-width: 92px;
  text-align:center;
  box-shadow: 0 12px 22px rgba(var(--p1-rgb),.22);
}

.server-copy-link{
  border: 0;
  background: transparent;
  padding: 0;
  font-weight: 900;
  color: rgba(var(--text-rgb),0.82);
  cursor:pointer;
}
.server-copy-link:hover{ text-decoration: underline; }

.server-total .server-copy-link{ display:none; }
.server-copy-spacer{ width: 1px; height: 1px; }

.server-item-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.server-item-name{
  font-weight: 900;
  color: var(--p4);
  font-size: 13px;
  line-height: 1.2;
}

.server-item-actions{
  margin-top: 10px;
  display:flex;
  justify-content:flex-end;
}

.server-copy-btn{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: none;
}
.progress{
  height: 10px;
  border-radius: 999px;
  background: rgba(var(--p4-rgb),.10);
  overflow:hidden;
  border: 1px solid rgba(var(--p4-rgb),.10);
}
.progress > div{
  height:100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--p1), var(--p2));
}
.server-row{
  margin-top: 10px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
}
.server-badge{
  background: rgba(var(--p1-rgb),.12);
  border: 1px solid rgba(var(--p1-rgb),.18);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 900;
  color: var(--p4);
}

.footer-note{
  margin: 14px 0 30px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-align:center;
}

/* Modal */
.modal-backdrop{
  position:fixed; inset:0;
  background: rgba(20,18,35,.55);
  display:none;
  /* Allow tall modals without inner scrollbars */
  align-items:flex-start; justify-content:center;
  overflow:auto;
  padding: 18px 18px 40px;
  z-index: 30;
}
.modal{
  width: min(860px, 100%);
  margin: 18px auto;
  background: var(--panel3);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
  overflow:hidden;
}
.modal-header{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3{margin:0; font-weight: 900; color: var(--p4)}
.modal-close{
  border:0;
  width: 38px; height:38px;
  border-radius: 14px;
  background: rgba(var(--p1-rgb),.12);
  border: 1px solid rgba(var(--p1-rgb),.18);
  cursor:pointer;
  font-weight: 900;
}
.modal-body{
  display:grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
}
.modal-img{
  border-radius: 18px;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.75), rgba(255,255,255,.10) 55%, transparent 70%),
              linear-gradient(135deg, rgba(var(--p3-rgb),.55), rgba(var(--p1-rgb),.30));
  height: 280px;
  display:grid;
  place-items:center;
  overflow:hidden;
}
.modal-img img{width:100%; height:100%; object-fit:cover}
.modal-desc{
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel2);
  padding: 14px;
  /* No inner scrollbar in the product modal */
  overflow: visible;
  max-height: none;
}

/* ==========================================================
   Product description HTML (tabs/panels)
   Supports blocks like: <div id="crom2-desc"> ...
   Works inside #modalDesc via JS (no URL hash changes).
   ========================================================== */

#modalDesc [id$="-desc"]{
  /*
    IMPORTANT:
    These variables MUST follow the active template (html[data-theme]).
    Previously this block hard-coded a light "paper" style, which caused
    white panels/buttons inside product descriptions even in dark themes.
  */
  /*
    Make the product description controls match the main modal buttons
    (more purple + subtle gradient shimmer).
  */
  --crom-accent: var(--p2);
  --crom-accent-1: var(--p1);
  --crom-accent-2: var(--p2);
  --crom-accent-3: var(--p3);
  --crom-ink: var(--text);
  --crom-paper1: var(--surface);
  --crom-paper2: var(--surface2);
  --crom-border: var(--line);
  --crom-shadow: var(--shadow2);

  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

#modalDesc [id$="-desc"] *{ box-sizing: border-box; }

/* Top pill ("ПРОПИСЫВАЕТСЯ НА 30 ДНЕЙ") */
#modalDesc a[id$="-pill30"]{
  display: block;
  width: min(600px, 100%);
  text-align: center;
  text-decoration: none;
  background: linear-gradient(90deg, var(--crom-accent-1), var(--crom-accent-2), var(--crom-accent-3), var(--crom-accent-2));
  background-size: 220% 220%;
  animation: cromDescShimmer 8s ease-in-out infinite;
  color: #fff !important;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .6px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(var(--p2-rgb), .22);
  text-transform: uppercase;
}

/* Tabs */
#modalDesc [id$="-nav"]{
  width: min(600px, 100%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

#modalDesc [id$="-nav"] a{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .55px;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--crom-accent) !important;
  border: 2px solid var(--crom-accent);
  box-shadow: 0 4px 10px rgba(0,0,0,.06);
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease;
}

#modalDesc [id$="-nav"] a:hover{
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(var(--p2-rgb), .14);
}

/* Active tab (added by JS) */
#modalDesc [id$="-nav"] a.crom-tab-active{
  background: linear-gradient(90deg, var(--crom-accent-1), var(--crom-accent-2), var(--crom-accent-3), var(--crom-accent-2));
  background-size: 220% 220%;
  animation: cromDescShimmer 8s ease-in-out infinite;
  color: #fff !important;
}

/* Panels wrapper */
#modalDesc [id$="-panels"]{
  width: min(600px, 100%);
}

/* Panel card */
#modalDesc [id$="-panels"] > div[data-title]{
  position: relative;
  margin-top: 6px;
  padding: 44px 18px 18px; /* top padding so label doesn't overlap first title */
  border-radius: 14px;
  background: linear-gradient(180deg, var(--crom-paper1), var(--crom-paper2));
  border: 1px solid var(--crom-border);
  box-shadow: var(--crom-shadow);
  color: var(--crom-ink);
  font-weight: 700;
  text-align: left;
  overflow: hidden;
}

/* Left accent stripe */
#modalDesc [id$="-panels"] > div[data-title]::before{
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  background: linear-gradient(180deg, var(--crom-accent-1), var(--crom-accent-2), var(--crom-accent-3));
  border-radius: 4px;
}

/* Panel title badge */
#modalDesc [id$="-panels"] > div[data-title]::after{
  content: attr(data-title);
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  padding: 6px 16px;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .5px;
  background: linear-gradient(90deg, var(--crom-accent-1), var(--crom-accent-2), var(--crom-accent-3), var(--crom-accent-2));
  background-size: 220% 220%;
  animation: cromDescShimmer 8s ease-in-out infinite;
  color: #fff;
  border-radius: 9px;
  text-transform: uppercase;
  box-shadow: 0 3px 10px rgba(0,0,0,.15);
}

@keyframes cromDescShimmer{
  0%{ background-position: 0% 50%; }
  50%{ background-position: 100% 50%; }
  100%{ background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce){
  #modalDesc a[id$="-pill30"],
  #modalDesc [id$="-nav"] a.crom-tab-active,
  #modalDesc [id$="-panels"] > div[data-title]::after{
    animation: none !important;
  }
}

/* ==========================================================
   Legacy inline-styled descriptions (old HTML stored in DB)
   Some product descriptions contain hard-coded light colors like
   background:#f8f8ff / #fff and text color:#20124D.
   On dark templates this keeps the inner "tiles" white.

   We override the most common legacy inline colors ONLY inside
   the product modal description container.
   ========================================================== */

/* Main white/near-white cards (apply ONLY on dark templates) */
html[data-theme^="dark"] #modalDesc [style*="background: #f8f8ff"],
html[data-theme^="dark"] #modalDesc [style*="background:#f8f8ff"],
html[data-theme^="dark"] #modalDesc [style*="background:rgb(248,248,255"],
html[data-theme^="dark"] #modalDesc [style*="background: rgb(248, 248, 255"],
html[data-theme^="dark"] #modalDesc [style*="background: #fff"],
html[data-theme^="dark"] #modalDesc [style*="background:#fff"],
html[data-theme^="dark"] #modalDesc [style*="background: #ffffff"],
html[data-theme^="dark"] #modalDesc [style*="background:#ffffff"]{
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow2) !important;
}

/* Light chips/badges often used inside privilege lists (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="background: #E8DBFA"],
html[data-theme^="dark"] #modalDesc [style*="background:#E8DBFA"],
html[data-theme^="dark"] #modalDesc [style*="background: rgb(232, 219, 250"],
html[data-theme^="dark"] #modalDesc [style*="background:rgb(232,219,250"]{
  background: var(--surface2) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
}

/* Very dark text used in light templates (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="color: #20124D"],
html[data-theme^="dark"] #modalDesc [style*="color:#20124D"],
html[data-theme^="dark"] #modalDesc [style*="color: rgb(32, 18, 77"],
html[data-theme^="dark"] #modalDesc [style*="color:rgb(32,18,77"]{
  color: var(--text) !important;
}

/* Purple dashed separators in legacy descriptions (dark templates only) */
html[data-theme^="dark"] #modalDesc hr[style*="dashed" i][style*="#A344E5" i]{
  border-top-color: var(--p1) !important;
}

/*
  Theme-normalize legacy description HTML.
  Old products often contain hardcoded inline light-theme styles.
  Broad rules below (paired with JS normalizer) ensure any theme applies.
*/

/* Any explicit background inside description becomes themed surface (keep bg images) (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="background" i]:not([style*="url(" i]){
  background: var(--surface) !important;
  background-color: var(--surface) !important;
}

/* Any explicit text color becomes theme text, except explicit accent (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="color" i]:not([style*="#a344e5" i]):not([style*="#7a3ec2" i]):not([style*="var(--p1)" i]){
  color: var(--text) !important;
}

/* Any explicit borders align to theme line (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="border" i]{
  border-color: var(--line) !important;
}

/* Any explicit shadow becomes themed shadow (dark templates only) */
html[data-theme^="dark"] #modalDesc [style*="box-shadow" i]{
  box-shadow: var(--shadow2) !important;
}

/* Inner helpers */
#modalDesc .crom-body{ font-size: 13.5px; line-height: 1.55; }
#modalDesc .crom-sep{ border: none; border-top: 2px dotted var(--crom-accent); opacity: .45; margin: 12px 0; }
#modalDesc .crom-link{
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .3px;
  background: var(--surface);
  color: var(--crom-accent) !important;
  border: 2px solid var(--crom-accent);
  box-shadow: 0 4px 10px rgba(0,0,0,.06);
}

@media (max-width: 520px){
  #modalDesc [id$="-nav"] a{ padding: 8px 12px; font-size: 11px; }
  #modalDesc [id$="-panels"] > div[data-title]{ padding: 44px 14px 14px; }
}

@media (max-width: 720px){
  .modal-body{grid-template-columns: 1fr;}
  .modal-img{height: 220px;}
}
.modal-actions{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 16px 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-btns{
  display:flex;
  align-items:center;
  gap: 10px;
}
.modal-btns .btn{
  min-width: 140px;
  justify-content:center;
}

@media (max-width: 460px){
  .modal-btns{ width: 100%; }
  .modal-btns .btn{ flex: 1; min-width: 0; }
}
.qty{
  display:flex; gap: 6px; align-items:center;
  background: rgba(var(--p1-rgb),.10);
  border: 1px solid rgba(var(--p1-rgb),.18);
  border-radius: 14px;
  padding: 6px 8px;
}
.qty button{
  width: 32px; height:32px;
  border:0; cursor:pointer;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-weight: 900;
}
.qty span{min-width: 26px; text-align:center; font-weight: 900; color: var(--p4)}

/* Cart drawer */
.drawer-backdrop{
  position:fixed; inset:0;
  background: rgba(20,18,35,.55);
  display:none;
  z-index: 40;
}
.drawer{
  position:fixed;
  right: 16px;
  top: 16px;
  width: min(420px, calc(100% - 32px));
  height: calc(100% - 32px);
  background: var(--panel3);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
  z-index: 41;
  display:none;
  flex-direction:column;
  overflow:hidden;
}
.drawer .head{
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display:flex; align-items:center; justify-content:space-between;
}
.drawer .head h3{margin:0; font-weight: 900; color: var(--p4)}
.drawer .items{
  padding: 12px 12px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.cart-item{
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px;
  display:grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items:center;
}
.cart-thumb{
  width:56px; height:56px;
  border-radius: 16px;
  overflow:hidden;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(var(--p3-rgb),.55), rgba(var(--p1-rgb),.30));
  display:grid; place-items:center;
}
.cart-thumb img{width:100%; height:100%; object-fit:cover}
.cart-name{font-weight: 900; color: var(--p4); font-size: 13px}
.cart-sub{color: var(--muted); font-weight: 700; font-size: 12px; margin-top:2px}
.cart-controls{
  display:flex; flex-direction:column; gap: 6px; align-items:flex-end;
}
.cart-controls .row{display:flex; gap:6px; align-items:center}
.cart-controls button{
  width: 30px; height:30px;
  border:0; cursor:pointer;
  border-radius: 12px;
  background: rgba(var(--p1-rgb),.10);
  border: 1px solid rgba(var(--p1-rgb),.18);
  font-weight: 900;
  color: var(--p4);
}
.drawer .foot{
  margin-top:auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  display:flex; flex-direction:column; gap: 10px;
}
.total-row{
  display:flex; justify-content:space-between; align-items:center;
  font-weight: 900;
  color: var(--p4);
}
.notice{
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

/* Snow effect */
.snowflake{
  position:fixed;
  top:-10px;
  color: var(--panel2);
  user-select:none;
  z-index: 20;
  pointer-events:none;
  text-shadow: 0 8px 20px rgba(0,0,0,.15);
}

/* Responsive */

@media (max-width: 1180px){
  .main-grid{grid-template-columns: 1fr 300px;}
  .product-grid{grid-template-columns: repeat(4, minmax(0, 1fr));}
}

@media (max-width: 980px){
  .main-grid{grid-template-columns: 1fr;}
  .sidebar{position:static}
  .product-grid{grid-template-columns: repeat(3, minmax(0, 1fr));}
  .banner-right{display:none}
}

@media (max-width: 720px){
  .product-grid{grid-template-columns: repeat(2, minmax(0, 1fr));}
}

@media (max-width: 420px){
  /* Keep 2 columns on phones (square tiles), reduce gaps and sizes */
  .container{padding: 14px;}
  .product-grid{grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;}
  .product-card{border-radius: 22px; padding: 12px 12px 14px; min-height: 210px;}
  .product-sticker{height: 120px;}
  .product-img,.product-img-fallback{width: 120px; height: 120px;}
  .product-name{font-size: 13px; min-height: 32px;}
  .product-price-pill{padding: 6px 7px;}
}

@media (max-width: 360px){
  .product-grid{grid-template-columns: 1fr;}
}


/* Layout hardening (prevents product grid drifting into sidebar) */
.content{min-width:0; grid-column:1;}
.sidebar{min-width:0; grid-column:2;}
@media (max-width: 980px){
  .sidebar{grid-column:1;}
}

/* Hide legacy filter/toolbars if any old markup is cached */
.toolbar,.filters,.pillbar{display:none!important;}


/* Auth modal (small) */
.modal.modal-small{
  max-width: 440px;
}
.modal-body-simple{
  display:block;
  padding: 16px 16px 18px;
}
.auth-note{
  margin: 0 0 14px;
  color: var(--p4);
  font-weight: 700;
  line-height: 1.35;
}


/* Topup modal helpers */
.field-row{
  display:flex;
  gap:10px;
  align-items:center;
  margin-top:10px;
}
.currency-pill{
  padding:10px 14px;
  border:1px solid rgba(79, 76, 108, 0.2);
  border-radius:14px;
  background:#fff;
  font-weight:700;
  color:#111827;
  min-width:56px;
  text-align:center;
}

/* --- Profile-style topup modal (used on main too) --- */
.pmodal{ position: fixed; inset: 0; z-index: 9999; }
.pmodal__backdrop{ position: absolute; inset: 0; background: rgba(0,0,0,0.35); backdrop-filter: blur(2px); }
.pmodal__card{
  position: relative;
  max-width: 520px;
  margin: 10vh auto 0;
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
@media (max-width: 520px){
  .pmodal__card{ margin: 12vh 12px 0; }
}
.pmodal__title{ font-weight: 900; color: var(--p4); margin-bottom: 12px; }
.pmodal__label{ font-weight: 800; color: rgba(var(--p4-rgb),0.75); margin-bottom: 8px; }
.pmodal__row{
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: center;
}
.pmodal__currency{
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  padding: 10px 12px;
  font-weight: 900;
  text-align: center;
  color: var(--p4);
}
.pmodal__input{
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.85);
  padding: 10px 12px;
  font-weight: 900;
  outline: none;
}
.pmodal__actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* --- Tablet / small desktop navbar (<=1024px): allow wrapping, put ADMIN on second row --- */
@media (max-width: 1024px){
  .navbar{
    flex-wrap: wrap;
    gap: 10px;
  }

  .navbar .nav-left{
    flex: 1 1 100%;
    min-width: 0;
  }

  .navbar .nav-right{
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* Force a line break right before #adminBtn without stretching the button */
  .navbar .nav-right::after{
    content: "";
    flex-basis: 100%;
    order: 999;
  }
  .navbar #adminBtn{
    order: 1000;
  }
}

/* --- Mobile navbar (<=576px): wrap controls into 2+ rows, no overflow --- */
@media (max-width: 576px){
  .navbar{
    flex-wrap: wrap;
    padding: 12px;
    gap: 10px;
  }

  .navbar .nav-left{
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    gap: 10px;
  }
  .navbar .brand{ font-size: 14px; line-height: 1.15; }
  .navbar .nav-link{ padding: 8px 10px; font-size: 13px; }

  .navbar .nav-right{
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
  }
  .navbar .nav-right > *{ min-width: 0; }

  /* Topup button: full width (first row) */
  .navbar .topup-header{
    grid-column: 1 / -1;
    width: 100%;
    padding: 12px 12px;
    border-radius: 16px;
    box-shadow: 0 10px 22px rgba(var(--p1-rgb),.18);
  }

  /* Balance tile */
  .navbar .balance{
    display:flex;
    align-items:center;
    justify-content:center;
    padding: 10px 10px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: none;
    font-size: 13px;
    white-space: normal;
    text-align: center;
  }

  /* Profile tile */
  .navbar .user-pill{
    width: 100%;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
  }
  .navbar .user-pill .btn.secondary{
    padding: 10px 10px;
    border-radius: 14px;
    white-space: nowrap;
    max-width: 100%;
  }

  /* Admin button: full width (third row) */
  .navbar #adminBtn{
    grid-column: 1 / -1;
    width: 100%;
    border-radius: 16px;
    padding: 10px 12px;
  }
}


/* =========================
   Theme enforcement
   Makes templates recolor UI even where legacy styles used hardcoded whites.
   ========================= */
html[data-theme^="dark"]{ color-scheme: dark; }

/* Native <select> dropdowns (option list) in Chromium can ignore page colors unless we style <option> */
html[data-theme^="dark"] select{ color-scheme: dark; }
html[data-theme^="dark"] select option,
html[data-theme^="dark"] select optgroup{
  background: var(--surface) !important;
  color: var(--text) !important;
}

/* Form controls */
input, select, textarea{
  background: var(--input-bg);
  color: var(--input-text);
  border-color: rgba(var(--text-rgb),0.14);
}
input::placeholder, textarea::placeholder{ color: rgba(var(--text-rgb),0.55); }

/* Common panels/cards/modals */
.card, .panel, .modal, .dialog, .pmodal__card{
  background: var(--surface) !important;
  color: var(--text);
  border-color: var(--line);
}

/* Small inner surfaces */
.currency-pill,
.pmodal__currency,
.pmodal__input,
.mono,
.table tr,
.table thead th{
  background: var(--surface2) !important;
  color: var(--text) !important;
}

/* Mobile card tables (cart/history) */
@media (max-width: 640px){
  .pb-table tr{
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
  }
  .pb-table td::before{ color: var(--muted) !important; }
}

/* Links / accents */
a{ color: var(--p1); }
.btn{ background: linear-gradient(180deg, var(--p1), var(--p2)); }
.btn.secondary{ background: rgba(var(--p1-rgb),0.10); border-color: rgba(var(--p1-rgb),0.22); color: var(--text); }


/* =========================
   Admin: Payments + Rich text editor theme
   ========================= */

/* Payments tab cards */
.pay-grid{
  display:flex;
  flex-direction:column;
  gap: 14px;
}

@media (min-width: 980px){
  .pay-grid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
}

.pay-card{
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow2);
  padding: 14px;
  display:flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
}

.pay-logo{
  width: 72px;
  flex: 0 0 72px;
  border-radius: 16px;
  background: var(--surface2);
  border: 1px solid rgba(var(--text-rgb),0.12);
  display:grid;
  place-items:center;
  padding: 10px;
}
.pay-logo img{ max-width: 56px; max-height: 36px; display:block; }

.pay-meta{ flex: 1 1 auto; min-width: 0; }
.pay-meta .muted{ color: var(--muted) !important; }

.pay-actions{
  flex: 0 0 auto;
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  justify-content:space-between;
  gap: 10px;
}

.badge.off{ background: rgba(255, 84, 84, .90); box-shadow: 0 10px 24px rgba(255, 84, 84, .25); }
.badge.req{ background: rgba(var(--p1-rgb), .85); }


/* Rich text editor (product description) */
.rt-wrap{
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
}

.rt-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
  padding: 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--line);
}

.rt-group{ display:flex; align-items:center; gap: 8px; }

.rt-btn{
  background: rgba(var(--p1-rgb),0.10);
  border: 1px solid rgba(var(--p1-rgb),0.22);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  font-weight: 900;
  cursor:pointer;
}
.rt-btn:hover{ filter: brightness(1.05); }

.rt-color{
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(var(--text-rgb),0.18);
  background: var(--surface);
}

.rt-editor{
  min-height: 240px;
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.rt-editor:empty::before{
  content: attr(data-placeholder);
  color: var(--muted);
}

.rt-source{
  width: 100%;
  border-top: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
}


/* --- Bulk selection visibility (default OFF) --- */
.bulk-only{ display:none !important; }
body.bulk-products .bulk-only{ display:inline-flex !important; }
body.bulk-products .bulk-only.btn{ justify-content:center; }

body:not(.bulk-products) .bulk-col{ display:none !important; }
body:not(.bulk-products) td.bulk-col{ display:none !important; }

/* Mobile bulk bar should never appear on desktop */
.bulk-mobilebar{ display:none; }



@media (max-width: 576px){
  .btn, .tab{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:100%;
  }
  .products-actions .bulk-exit{
    grid-column:1 / -1;
    width:100%;
    /* Allow full label on mobile */
    white-space:normal;
    overflow:visible;
    text-overflow:clip;
    line-height:1.15;
    font-size:12px;
    padding-top:12px;
    padding-bottom:12px;
    text-align:center;
  }
}

