: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; }

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;
}

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: 1.25rem;
}

.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.3rem; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 0.85rem;
  border-radius: 12px;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.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;
}

.sidebar-foot {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.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;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  letter-spacing: -0.03em;
}
.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;
}

.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;
  gap: 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; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
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; }

.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;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
}

@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); }
}

@media (max-width: 1100px) {
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(110%);
    transition: transform 0.25s var(--ease);
    z-index: 40;
    border-left: 0;
    border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: none; }
  .mobile-toggle { display: inline-flex; }
  .main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
}
.overlay.show { display: block; }

.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); }

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; }
