:root {
  --bg: #070b10;
  --bg-elevated: #0d141c;
  --surface: #121a24;
  --surface-2: #182230;
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --danger: #fb7185;
  --warning: #fbbf24;
  --success: #34d399;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --nav-w: 260px;
  --font-fa: "Vazirmatn", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Sora", "Vazirmatn", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-fa);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(45, 212, 191, 0.08), transparent 55%),
    radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, 0.07), transparent 50%),
    linear-gradient(180deg, #070b10 0%, #0a1018 100%);
  line-height: 1.6;
  overflow-x: hidden;
}
body.nav-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.25rem 1rem;
  background: rgba(8, 12, 18, 0.92);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.35rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #041016;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 10px 30px rgba(45, 212, 191, 0.25);
}

.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.brand-text span {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-left: 0.15rem;
  padding-right: 0.15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.62rem 0.8rem;
  border-radius: 12px;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
  flex-shrink: 0;
}
.nav a:hover { background: var(--surface); color: var(--text); transform: translateX(-2px); }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.2);
}
.nav-ico {
  width: 1.35rem;
  text-align: center;
  opacity: 0.9;
  flex-shrink: 0;
}
.nav-section {
  margin: 0.65rem 0.35rem 0.35rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.sidebar-foot {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 0.85rem 0.75rem 0.35rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, rgba(8, 12, 18, 0.65) 18%);
}
.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.7rem;
  min-width: 0;
}
.sidebar-user-name {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: var(--muted);
  font-size: 0.75rem;
}
.sidebar-logout {
  width: 100%;
  margin: 0;
}
.sidebar-logout .btn {
  width: 100%;
}

.main {
  padding: 1.35rem 1.5rem 2.5rem;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.35rem;
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}
.topbar-titles { min-width: 0; }
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: 0 0 auto;
  margin-inline-start: auto;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.75rem);
  letter-spacing: -0.03em;
  line-height: 1.3;
  word-break: break-word;
}
.page-sub { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease), box-shadow 0.15s var(--ease);
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #14b8a6);
  color: #04201c;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(45, 212, 191, 0.22);
}
.btn-primary:hover { box-shadow: 0 14px 34px rgba(45, 212, 191, 0.32); }
.btn-ghost { background: transparent; border: 1px solid var(--border-strong); }
.btn-danger { background: rgba(251, 113, 133, 0.12); color: var(--danger); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.85rem; border-radius: 10px; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.stat {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  animation: rise 0.5s var(--ease) both;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }
.stat::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45,212,191,0.18), transparent 70%);
  pointer-events: none;
}
.stat-label { color: var(--muted); font-size: 0.82rem; }
.stat-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin-top: 0.2rem;
}
.stat-value-sm { font-size: 1.35rem; }
.stat-meta {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.stat-link {
  display: block;
  color: inherit;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.stat-link:hover {
  border-color: rgba(45, 212, 191, 0.35);
  transform: translateY(-2px);
}

/* Dashboard */
.dash { display: grid; gap: 1rem; }
.dash-stats { margin-bottom: 0; }
.dash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.dash-main { margin-top: 0; }
.dash-secondary { margin-top: 0; }
.panel-link {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}
.panel-link:hover { text-decoration: underline; }
.dash-user {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  color: inherit;
}
.dash-user strong { font-size: 0.92rem; }
.dash-user span {
  color: var(--muted);
  font-size: 0.76rem;
}
.dash-pkg {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.dash-pkg strong { font-size: 0.9rem; }
.cell-meta {
  color: var(--muted);
  font-size: 0.78rem;
}
.muted { color: var(--muted); }
tr.is-inactive td { opacity: 0.55; }
.dash-content-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}
.dash-content-grid a {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(7, 11, 16, 0.55);
  border: 1px solid var(--border);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.dash-content-grid a:hover {
  border-color: rgba(45, 212, 191, 0.3);
  background: var(--accent-soft);
}
.dash-content-grid span {
  color: var(--muted);
  font-size: 0.75rem;
}
.dash-content-grid strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.03em;
}
.dash-cdn { display: grid; gap: 0.75rem; }
.dash-cdn-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.dash-cdn-links code {
  font-size: 0.72rem;
  padding: 0.28rem 0.5rem;
  border-radius: 8px;
  background: #070b10;
  border: 1px solid var(--border);
  color: #9fb3c8;
}
.dash-cdn-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  background: rgba(18, 26, 36, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.panel-h h2 {
  margin: 0;
  font-size: 1rem;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.panel-b { padding: 1.1rem; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 520px;
}
table.data th,
table.data td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  background: rgba(255,255,255,0.02);
}
table.data tr:hover td { background: rgba(255,255,255,0.015); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge-ok { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.badge-off { background: rgba(148, 163, 184, 0.12); color: var(--muted); }
.badge-vip { background: rgba(251, 191, 36, 0.14); color: var(--warning); }
.badge-lang { background: var(--accent-soft); color: var(--accent); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }

label.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}
label.field > span { font-weight: 600; color: #c5d0de; }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}
.textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-size: 0.9rem;
}
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.alert {
  padding: 0.8rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  animation: rise 0.35s var(--ease);
}
.alert-success { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.25); color: #a7f3d0; }
.alert-error { background: rgba(251, 113, 133, 0.1); border-color: rgba(251, 113, 133, 0.25); color: #fecdd3; }

/* Previews */
.preview-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a1017;
}
.preview-stage {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
}
.preview-text {
  font-size: 1.55rem;
  text-align: center;
  line-height: 1.45;
  max-width: 90%;
  word-break: break-word;
}
.font-preview-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.font-swatch {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 1.4rem;
  font-weight: 700;
}

.bg-thumb {
  width: 100%;
  height: 88px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.bg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}
.bg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.bg-card:hover { transform: translateY(-3px); border-color: rgba(45, 212, 191, 0.35); }
.bg-card .meta { padding: 0.85rem 0.95rem 1rem; }
.bg-card h3 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.bg-card p { margin: 0; color: var(--muted); font-size: 0.8rem; }

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}
.style-chrome {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(86%, 220px);
  gap: 0;
}
.style-chrome img {
  width: 100%;
  height: auto;
  display: block;
}
.chrome-meta {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.chrome-meta code { font-size: 0.7rem; word-break: break-all; }
.chrome-preview {
  display: grid;
  gap: 0.85rem;
}
.chrome-preview small {
  display: block;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.chrome-preview img {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.chrome-preview code {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.style-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.style-thumb {
  min-height: 140px;
  height: auto;
  padding: 0.85rem 0;
  background: #0a1017 center/cover no-repeat;
  display: grid;
  place-items: center;
  position: relative;
}
.style-live {
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  text-align: center;
  line-height: 1.35;
  max-width: 100%;
  word-break: break-word;
  box-sizing: border-box;
  background-color: #1a7a7a;
  color: #fff;
}
.style-card .meta { padding: 0.85rem; }

.preview-stage .style-chrome {
  width: min(92%, 280px);
}
.preview-stage .style-live {
  font-size: 1.05rem;
  min-width: 140px;
}
.preview-sticky {
  position: sticky;
  top: 1rem;
  align-self: start;
}

.split-2 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1rem;
  align-items: start;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.login-wrap::before,
.login-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  pointer-events: none;
}
.login-wrap::before {
  width: 420px; height: 420px;
  background: rgba(45, 212, 191, 0.16);
  top: -120px; left: -80px;
  animation: drift 10s ease-in-out infinite alternate;
}
.login-wrap::after {
  width: 360px; height: 360px;
  background: rgba(56, 189, 248, 0.12);
  bottom: -100px; right: -60px;
  animation: drift 12s ease-in-out infinite alternate-reverse;
}
.login-card {
  width: min(420px, 100%);
  background: rgba(13, 20, 28, 0.9);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  animation: rise 0.55s var(--ease);
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}
.login-card .lead { color: var(--muted); margin: 0 0 1.25rem; font-size: 0.92rem; }

.captcha-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 0.5rem;
  align-items: center;
}
.captcha-img {
  width: 160px;
  height: 52px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #070b10;
  object-fit: cover;
}
.captcha-input {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
}

.cdn-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  background: #070b10;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  color: #9fb3c8;
  word-break: break-all;
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
}

.mobile-toggle {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-top: 0.1rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 10px;
  padding: 0;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}
.mobile-toggle:hover { border-color: rgba(45, 212, 191, 0.35); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes drift {
  from { transform: translate(0, 0); }
  to { transform: translate(30px, 20px); }
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
  backdrop-filter: blur(2px);
}
.overlay.show { display: block; }

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-2 { grid-template-columns: 1fr; }
  .dash-content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-sticky { position: static; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }

  /* Drawer docks to inline-start (right in RTL) and slides off-screen when closed */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: auto;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
    transform: translateX(110%);
    transition: transform 0.28s var(--ease);
    z-index: 40;
    border-left: 0;
    border-inline-end: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  html[dir="rtl"] .sidebar { transform: translateX(110%); }
  html:not([dir="rtl"]) .sidebar { transform: translateX(-110%); }
  .sidebar.open,
  html[dir="rtl"] .sidebar.open,
  html:not([dir="rtl"]) .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle { display: inline-flex; }
  .main { padding: 0.9rem 0.85rem 1.75rem; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1rem;
  }
  .topbar-start { align-items: flex-start; }
  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }
  .topbar-actions .btn { flex: 1 1 auto; }
  .form-grid { grid-template-columns: 1fr; }
  .panel-b { padding: 0.9rem; }
  .panel-h { padding: 0.85rem 0.9rem; }
  .filter-bar { padding: 0.75rem; }
  .filter-item { min-width: 0; flex: 1 1 100%; }
  .filter-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .filter-actions .btn { flex: 1 1 auto; }
  .captcha-row {
    grid-template-columns: 1fr;
  }
  .captcha-img { width: 100%; height: 56px; }
  .bg-grid,
  .style-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .font-preview-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-modal { padding: 0.5rem; align-items: end; }
  .admin-modal-card {
    width: 100%;
    max-height: min(94dvh, 94vh);
    border-radius: 16px 16px 12px 12px;
  }
  .admin-toast {
    inset-inline: 0.75rem;
    bottom: 0.75rem;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .grid-stats { grid-template-columns: 1fr; }
  .dash-content-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.55rem; }
  table.data {
    font-size: 0.84rem;
    min-width: 480px;
  }
  table.data th,
  table.data td {
    padding: 0.65rem 0.7rem;
  }
  .btn {
    padding: 0.6rem 0.85rem;
  }
  .segment-nav {
    width: 100%;
  }
  .segment-nav-item {
    flex: 1 1 auto;
    justify-content: center;
  }
  .login-card { padding: 1.25rem; }
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-item {
  display: grid;
  gap: 0.3rem;
  min-width: 140px;
  flex: 1 1 140px;
}
.filter-item > span {
  font-size: 0.78rem;
  color: var(--muted);
}
.filter-item .input,
.filter-item .select {
  width: 100%;
}
.filter-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex: 0 0 auto;
  padding-bottom: 0.05rem;
}

.switch-form { margin: 0; }
.switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
}
.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.switch-knob {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  transition: inset-inline-start 0.2s var(--ease), inset-inline-end 0.2s var(--ease), background 0.2s var(--ease);
}
.switch.is-on .switch-track {
  background: rgba(45, 212, 191, 0.28);
  border-color: rgba(45, 212, 191, 0.45);
}
.switch.is-on .switch-knob {
  inset-inline-start: auto;
  inset-inline-end: 2px;
  background: var(--accent);
}
.switch-text {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 3.2rem;
}
.switch.is-on .switch-text { color: var(--success); }

.vip-switch.is-on .switch-track {
  background: rgba(251, 191, 36, 0.35);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45);
}
.vip-switch.is-on .switch-knob { background: var(--warning); }
.vip-switch.is-on .switch-text { color: var(--warning); }
.vip-switch-form.is-busy { opacity: 0.6; pointer-events: none; }

tr.is-inactive,
.style-card.is-inactive,
.bg-card.is-inactive {
  opacity: 0.55;
  filter: grayscale(0.25);
}

.import-panel { margin-bottom: 1.25rem; }
.import-panel .lead { color: var(--muted); font-size: 0.88rem; }
.import-form { display: grid; gap: 0.85rem; }
.import-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: flex-end;
}
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.82rem; color: var(--muted); }
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

/* Color fields — LTR + Pickr swatches */
.color-field {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  direction: ltr;
  text-align: left;
}

.color-swatch {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background:
    linear-gradient(var(--swatch, #fff), var(--swatch, #fff)),
    repeating-conic-gradient(#2a3340 0% 25%, #1a222c 0% 50%) 50% / 12px 12px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 6px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.color-swatch:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2);
}

.color-field .color-hex {
  flex: 1;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.color-list-field {
  display: grid;
  gap: 0.65rem;
  direction: ltr;
  text-align: left;
}
.color-list-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.color-add-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.color-add-btn:hover {
  border-color: rgba(45, 212, 191, 0.45);
  color: var(--accent);
}

/* Pickr dark theme tweaks */
.pcr-app {
  background: #121a24 !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow) !important;
  font-family: var(--font-fa) !important;
  z-index: 10050 !important;
}
.pcr-app[data-theme='nano'] .pcr-selection .pcr-color-chooser,
.pcr-app[data-theme='nano'] .pcr-selection .pcr-color-opacity {
  height: 0.55em;
}
.pcr-app .pcr-interaction input {
  background: #0b1016 !important;
  color: var(--text) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 8px !important;
  direction: ltr;
  text-align: left;
}
.pcr-app .pcr-interaction .pcr-save {
  background: var(--accent) !important;
  color: #041016 !important;
  border-radius: 8px !important;
  font-weight: 700;
}
.pcr-app .pcr-interaction .pcr-type.active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
}

/* CodeMirror JSON editor */
.json-editor + .CodeMirror,
.CodeMirror {
  direction: ltr;
  text-align: left;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  background: #0b1016 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  min-height: 180px;
}
.CodeMirror-focused {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.12);
}
.CodeMirror-gutters {
  background: #0a0f15 !important;
  border-right: 1px solid var(--border) !important;
}
.CodeMirror-linenumber { color: #5b6b7c !important; }
.cm-s-material-darker.CodeMirror {
  background: #0b1016 !important;
  color: #e6edf5 !important;
}
.cm-s-material-darker .CodeMirror-cursor { border-left: 1px solid #2dd4bf; }

.segment-nav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0 0 1rem;
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.segment-nav-item {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.9rem;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.segment-nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}
.segment-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
button.segment-nav-item {
  border: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

.sales-chart-panel {
  margin-bottom: 1rem;
}
.sales-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.sales-chart-summary {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.sales-chart-tabs {
  margin: 0;
}
.sales-chart-body {
  padding: 0.35rem 1rem 1.1rem;
  height: 280px;
}
@media (max-width: 720px) {
  .sales-chart-body { height: 220px; }
}

.filter-hint {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.85;
  white-space: nowrap;
}
.filter-bar.is-loading {
  opacity: 0.72;
  pointer-events: none;
}
[data-ajax-list].is-loading {
  opacity: 0.55;
  transition: opacity 0.15s var(--ease);
}

.admin-modal[hidden] { display: none !important; }
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(8px);
}
.admin-modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background:
    linear-gradient(180deg, rgba(24, 34, 48, 0.98), rgba(12, 18, 28, 0.98));
  box-shadow: var(--shadow);
}
.admin-modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 18, 28, 0.92);
  backdrop-filter: blur(10px);
}
.admin-modal-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.admin-modal-x {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.admin-modal-x:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.04); }
.admin-modal-body { padding: 1.1rem 1.15rem 1.25rem; }
.admin-modal-body .panel {
  max-width: none !important;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.admin-modal-body .panel-h { display: none; }
.admin-modal-body .panel-b { padding: 0; }

.admin-toast[hidden] { display: none !important; }
.admin-toast {
  position: fixed;
  inset-inline-end: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(18, 26, 36, 0.96);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}
.admin-toast.is-ok {
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--success);
}
.admin-toast.is-err {
  border-color: rgba(251, 113, 133, 0.4);
  color: var(--danger);
}
