:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --side: #0b1829;
  --side-hover: rgba(255, 255, 255, 0.06);
  --line: #e5e9f0;
  --text: #1b2430;
  --muted: #6a7689;
  --yellow: #f5c400;
  --yellow-dark: #e0b000;
  --ok: #1f9d65;
  --danger: #d64545;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 27, 42, 0.07);
  --font: 'Ukij Tuz Tom', 'UKIJ Ekran', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --side-w: 268px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  direction: rtl;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.25em; margin: 0; }

/* ——— كىرىش：سولدا فورم، ئوڭدا ماركا ——— */
.login-split {
  min-height: 100vh;
  display: grid;
  direction: ltr;
  grid-template-columns: minmax(360px, 0.95fr) minmax(400px, 1.05fr);
}
.login-panel,
.login-brand,
.login-form,
.login-brand-inner { direction: rtl; }

.login-brand {
  background:
    radial-gradient(700px 420px at 80% 0%, rgba(245,196,0,.18), transparent 60%),
    linear-gradient(160deg, #08131f 0%, #12263a 55%, #0b1829 100%);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-brand-inner { max-width: 520px; width: 100%; }
.logo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 36px; }
.logo-mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--yellow); color: #111; display: grid; place-items: center;
  font-weight: 700; font-size: 1.4rem; flex-shrink: 0;
}
.logo-mark.sm { width: 40px; height: 40px; font-size: 1.15rem; border-radius: 10px; }
.logo-name { font-weight: 700; font-size: 1.05rem; }
.logo-sub { color: rgba(255,255,255,.55); font-size: .85rem; margin-top: 2px; }
.brand-slogan {
  font-size: clamp(1.55rem, 2.4vw, 2.1rem);
  line-height: 1.55;
  margin: 0 0 14px;
  font-weight: 700;
}
.brand-slogan em { font-style: normal; color: var(--yellow); }
.brand-desc {
  color: rgba(255,255,255,.62);
  line-height: 1.9;
  margin: 0 0 28px;
  font-size: .95rem;
}
.feat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.feat {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.feat-ico {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1.5px solid var(--yellow); color: var(--yellow);
  display: grid; place-items: center; flex-shrink: 0; font-size: .9rem;
}
.feat b { display: block; font-size: .92rem; margin-bottom: 4px; }
.feat small { color: rgba(255,255,255,.5); font-size: .8rem; }

.login-panel {
  background: #fff;
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.login-form { width: min(400px, 92vw); display: grid; gap: 14px; }
.login-form h1 { margin: 0; font-size: 1.75rem; font-weight: 700; }
.login-hint { margin: 0 0 6px; color: var(--muted); }
.tabs {
  display: grid;
  background: #f3f5f8;
  border-radius: 999px;
  padding: 4px;
}
.tab {
  text-align: center;
  padding: 10px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--yellow);
  color: #111;
}
.inp { display: grid; gap: 8px; font-size: .9rem; color: var(--muted); }
.inp-box { position: relative; }
.inp-box input {
  width: 100%;
  border: 1px solid #d8dee8;
  border-radius: 12px;
  padding: 12px 42px 12px 14px;
  background: #fff;
  outline: none;
}
.inp-box input:focus { border-color: var(--yellow-dark); }
.inp-box .ico {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  color: #9aa3b2; font-style: normal;
}
.btn-yellow {
  margin-top: 6px;
  border: 0;
  border-radius: 12px;
  padding: 13px;
  background: var(--yellow);
  color: #111;
  font-weight: 700;
  cursor: pointer;
  font-size: 1.05rem;
}
.btn-yellow:hover { background: var(--yellow-dark); }

/*
  ئاساسىي ئورۇنلاشتۇرۇش（جۇغراپىيەلىك）：
  سول = ئىستاتىستىكا / مەزمۇن
  ئوڭ = مېنيۇ
  direction:ltr بىلەن قاتتىق بېكىتىمىز（rtl grid تەتۈر قىلىۋېتىدۇ）
*/
.layout {
  display: grid;
  direction: ltr;
  grid-template-columns: minmax(0, 1fr) var(--side-w);
  min-height: 100vh;
  width: 100%;
}
.main,
.side,
.page,
.topbar,
.modal-card { direction: rtl; }

.side {
  background: var(--side);
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
}
.side-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
}
.side .logo-name { color: #fff; line-height: 1.35; }
.side .logo-sub { color: rgba(255,255,255,.45); }

#nav { display: grid; gap: 4px; flex: 1; align-content: start; }
#nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  color: rgba(255,255,255,.68);
  transition: background .15s, color .15s;
}
#nav button .nav-ico {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: .85;
  display: grid;
  place-items: center;
}
#nav button .nav-ico svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#nav button:hover {
  background: var(--side-hover);
  color: #fff;
}
#nav button.active {
  background: var(--yellow);
  color: #111;
  font-weight: 700;
}
#nav button.active .nav-ico { opacity: 1; }

.logout {
  margin-top: 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  padding: 11px;
  color: #ff9a9a !important;
  cursor: pointer;
}
.logout:hover { background: rgba(214,69,69,.12); }

.main {
  padding: 22px 28px 40px;
  min-width: 0;
  background: var(--bg);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  gap: 12px;
}
.topbar h2 { margin: 0; font-size: 1.45rem; font-weight: 700; }
.page-date { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.who-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .9rem;
  box-shadow: var(--shadow);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 92px;
}
.card .meta .n { font-size: 1.65rem; font-weight: 700; line-height: 1.2; letter-spacing: 0; }
.card .meta .l { color: var(--muted); font-size: .88rem; margin-top: 6px; }
.card .ico-box {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.15rem; flex-shrink: 0;
}
.card .ico-box.y { background: rgba(245,196,0,.18); color: #b88600; }
.card .ico-box.g { background: rgba(31,157,101,.14); color: var(--ok); }
.card .ico-box.b { background: rgba(50,110,200,.12); color: #3b6fd8; }
.card .ico-box.p { background: rgba(140,80,200,.12); color: #8a4fd1; }
.card .ico-box.r { background: rgba(214,69,69,.12); color: var(--danger); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 1.05rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}
.toolbar input, .toolbar select,
.field input, .field select, .field textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
}
.toolbar input[type="search"] { min-width: 200px; }

.btn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn:hover { border-color: #c9d0db; }
.btn.primary {
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 700;
  color: #111;
}
.btn.danger { color: var(--danger); border-color: #f0c4c4; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: #f7f9fc;
  position: sticky; top: 0;
}
tr:hover td { background: #fafbfd; }
.poster {
  width: 42px; height: 58px; object-fit: cover;
  border-radius: 6px; background: #dde3ec;
}
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .75rem;
  background: #eef1f5;
  color: var(--muted);
  margin-left: 4px;
}
.tag.on { background: rgba(245,196,0,.2); color: #9a7600; }
.tag.ok { background: rgba(31,157,101,.12); color: var(--ok); }
.tag.warn { background: rgba(214,69,69,.1); color: var(--danger); }

.pager {
  display: flex; gap: 8px; align-items: center;
  margin-top: 12px; justify-content: flex-start;
}
.dash-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: .9fr 1.4fr;
}

.modal {
  position: fixed; inset: 0; background: rgba(10,18,28,.55);
  display: grid; place-items: center; z-index: 50; padding: 16px;
  direction: ltr;
}
.modal-card {
  width: min(740px, 96vw); max-height: 90vh; overflow: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.modal-head h3 { margin: 0; }
.icon-btn { background: transparent; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); }
#modal-body { padding: 16px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; }
.field label { font-size: .85rem; color: var(--muted); }
.checks { display: flex; flex-wrap: wrap; gap: 12px; }
.checks label { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: .9rem; }
.form-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 8px; }

.ep-block { background: #f6f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.ep-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.ep-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.ep-fields { display: grid; gap: 8px; }
.ep-fields input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.ep-fmt-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ep-fmt-bar .ep-fmt {
  min-width: 72px;
  text-transform: lowercase;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}
.ep-fmt-bar .ep-fmt.on {
  background: #f5c518;
  border-color: #e0b000;
  color: #111;
  font-weight: 700;
}
.btn.danger { color: #b42318; border-color: #f3b0a8; background: #fff5f4; }

.user-vip-switch {
  background: #fff8e8;
  border: 1px solid #f0d78c;
  border-radius: 10px;
  padding: 12px 14px;
}
.audit-panel h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.audit-state {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #6b7280;
}
.vip-switch-lab {
  display: flex !important;
  align-items: center;
  gap: 10px;
  color: var(--text) !important;
  font-size: 0.95rem !important;
  font-weight: 600;
}
.vip-switch-lab input {
  width: 18px;
  height: 18px;
}

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #132337; color: #fff;
  padding: 11px 18px; border-radius: 999px; z-index: 60;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.toast.err { background: #7a1f1f; }

.help {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  line-height: 2;
  box-shadow: var(--shadow);
}
.help ol { padding-right: 22px; margin: 8px 0; }
.cj-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.cj-classes-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.cj-classes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cj-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  color: #c62828;
}
.cj-chip.on {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
}
.cj-log {
  margin-top: 12px;
  max-height: 240px;
  overflow: auto;
  background: #111;
  color: #9fef9f;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  direction: ltr;
  text-align: left;
}
.ellip {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.filter-block .head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}

.avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #e8eef5;
  vertical-align: middle;
}
.order-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px;
}
.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--muted);
}
.tab-btn.on {
  background: var(--side);
  color: #fff;
  border-color: var(--side);
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 0 4px;
}
.inp-search {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.btn.sm { padding: 6px 10px; font-size: 0.85rem; }
.btn.danger { background: #fdecec; color: var(--danger); border: 1px solid #f5c2c2; }
.tag.warn { background: #fff4e0; color: #b86a00; }

@media (max-width: 980px) {
  .login-split { grid-template-columns: 1fr; }
  .login-brand { order: -1; padding: 32px 24px; }
  .layout {
    grid-template-columns: 1fr;
  }
  .side {
    position: relative;
    height: auto;
    order: -1;
    max-height: none;
  }
  #nav { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
