/* tg-theme:start */
:root {
  /* sirtlar */
  --tg-bg: #0a0a0b;           /* sahifa foni */
  --tg-surface: #141416;      /* kartochka, panel */
  --tg-surface-2: #1b1b1f;    /* hover, ko'tarilgan element */
  --tg-surface-3: #232328;    /* chip, faol segment */
  --tg-input: #0e0e10;        /* input / textarea / select foni */
  --tg-line: rgba(255, 255, 255, 0.07);   /* kartochka chegarasi, ajratgich */
  --tg-line-2: rgba(255, 255, 255, 0.12); /* input chegarasi, hover chegara */

  /* matn */
  --tg-text: #f4f4f5;
  --tg-muted: #8e8e97;
  --tg-dim: #5f5f68;

  /* urg'u — lime */
  --tg-accent: #d2ff1f;
  --tg-accent-hover: #dcff52;
  --tg-accent-ink: #0a0a0b;               /* lime ustidagi matn */
  --tg-accent-soft: rgba(210, 255, 31, 0.1);
  --tg-accent-line: rgba(210, 255, 31, 0.35);

  /* holatlar */
  --tg-ok: #7ee787;
  --tg-ok-soft: rgba(126, 231, 135, 0.12);
  --tg-warn: #f5c451;
  --tg-warn-soft: rgba(245, 196, 81, 0.12);
  --tg-bad: #ff6b6b;
  --tg-bad-soft: rgba(255, 107, 107, 0.12);

  /* shakl */
  --tg-radius-sm: 8px;   /* chip, kichik tugma, kod */
  --tg-radius: 10px;     /* tugma, input */
  --tg-radius-lg: 14px;  /* kartochka, panel, modal */
  --tg-control-h: 38px;  /* tugma/input balandligi */

  /* shrift */
  --tg-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --tg-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --tg-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); /* faqat modal/toast/menyu */
  color-scheme: dark;
}
/* tg-theme:end */

/* TGLink paneli — TG Hub yagona dizayni (design/DESIGN.md). Ranglar faqat var(--tg-*) orqali. */

/* ─────────────── asos ─────────────── */
* { box-sizing: border-box; }
html { background: var(--tg-bg); scrollbar-color: #2a2a30 transparent; scrollbar-width: thin; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--tg-bg);
  color: var(--tg-text);
  font: 14px/1.45 var(--tg-font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--tg-accent); color: var(--tg-accent-ink); }
:focus-visible { outline: 2px solid var(--tg-accent); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a2a30; border-radius: 10px; border: 2px solid var(--tg-bg); }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.muted { color: var(--tg-muted); }
.spacer { flex: 1; }
.grow { flex: 1 1 220px; }
.narrow { flex: 0 0 120px; }

/* ─────────────── maydonlar ─────────────── */
input, select {
  width: 100%;
  height: var(--tg-control-h);
  padding: 0 12px;
  background-color: var(--tg-input);
  border: 1px solid var(--tg-line-2);
  border-radius: var(--tg-radius);
  color: var(--tg-text);
  font: 14px var(--tg-font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--tg-dim); }
input:hover, select:hover { border-color: rgba(255, 255, 255, 0.18); }
input:focus, select:focus,
input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--tg-accent-line);
  box-shadow: 0 0 0 3px var(--tg-accent-soft);
}
input[type=number] { font-family: var(--tg-mono); font-size: 13px; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--tg-muted) 50%),
    linear-gradient(135deg, var(--tg-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
option { background: var(--tg-surface-2); color: var(--tg-text); }

input[type=checkbox] {
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--tg-accent);
  cursor: pointer;
  vertical-align: middle;
}
input[type=checkbox]:focus { box-shadow: none; }

label { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label > span { font-size: 12.5px; color: var(--tg-muted); }
label em { font-style: normal; color: var(--tg-dim); }

/* ─────────────── tugmalar ─────────────── */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--tg-control-h);
  padding: 0 16px;
  border: 1px solid var(--tg-line-2);
  border-radius: var(--tg-radius);
  background: var(--tg-surface);
  color: var(--tg-text);
  font: 500 14px var(--tg-font);
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:hover { background: var(--tg-surface-2); border-color: rgba(255, 255, 255, 0.18); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* asosiy — sahifadagi bosh amal (lime) */
button.primary, .login-box button {
  border: 0;
  background: var(--tg-accent);
  color: var(--tg-accent-ink);
  font-weight: 700;
}
button.primary:hover, .login-box button:hover { background: var(--tg-accent-hover); }
button.primary:disabled:hover, .login-box button:disabled:hover { background: var(--tg-accent); }

/* ikkinchi darajali */
button.ghost { background: var(--tg-surface); border-color: var(--tg-line-2); color: var(--tg-text); }
button.ghost:hover { background: var(--tg-surface-2); border-color: rgba(255, 255, 255, 0.18); }

/* xavfli */
button.danger { background: var(--tg-bad-soft); border-color: rgba(255, 107, 107, 0.25); color: var(--tg-bad); }
button.danger:hover { background: rgba(255, 107, 107, 0.18); border-color: rgba(255, 107, 107, 0.4); }

button.small { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: var(--tg-radius-sm); }

/* ─────────────── brend belgisi (28px lime kvadrat + qora havola belgisi) ─────────────── */
.brand, .login-box h1 { position: relative; }
.brand::before, .login-box h1::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  border-radius: var(--tg-radius-sm);
  background: var(--tg-accent);
}
.brand::after, .login-box h1::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  background: var(--tg-accent-ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ─────────────── kirish ─────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-box {
  width: min(380px, 100%);
  padding: 28px;
  background: var(--tg-surface);
  border: 1px solid var(--tg-line-2);
  border-radius: var(--tg-radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-box h1 {
  margin: 0;
  padding-top: 52px;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.login-box h1::before { top: 0; margin-top: 0; width: 40px; height: 40px; border-radius: var(--tg-radius); }
.login-box h1::after { top: 10px; left: 10px; margin-top: 0; width: 20px; height: 20px; }
.login-box p { margin: -6px 0 8px; font-size: 13px; }
.login-box input { height: 40px; }
.login-box button { width: 100%; height: 40px; }
.error { color: var(--tg-bad); font-size: 12.5px; }
.error:empty { display: none; }

/* ─────────────── sahifa karkasi ─────────────── */
main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─────────────── sarlavha qatori + statistika ─────────────── */
.topbar { display: flex; align-items: center; gap: 16px; min-height: 40px; }
.brand {
  padding-left: 38px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.2;
  flex: none;
}
.stats {
  display: flex;
  align-items: center;
  margin-left: auto;
  min-height: var(--tg-control-h);
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius);
  background: var(--tg-surface);
  overflow: hidden;
}
.stats:empty { display: none; }
.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 22px;
  padding: 0 14px;
  white-space: nowrap;
}
.stat + .stat { border-left: 1px solid var(--tg-line); }
.stat b {
  font-family: var(--tg-mono);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tg-text);
}
.stat span {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tg-muted);
}

/* ─────────────── yaratish kartochkasi ─────────────── */
.panel {
  background: var(--tg-surface);
  border: 1px solid var(--tg-line);
  border-radius: var(--tg-radius-lg);
}
.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tg-line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--tg-muted);
  font-size: 14px;
  font-weight: 500;
}
.tab:hover { color: var(--tg-text); background: rgba(255, 255, 255, 0.04); border: 0; }
.tab:active { transform: none; }
.tab.active { color: var(--tg-accent); }
.tab.active:hover { color: var(--tg-accent); }
.tab:focus-visible { outline-offset: -2px; }

.form { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 2px; }
.msg { font-size: 12.5px; color: var(--tg-muted); }
.msg:empty { display: none; }
.msg.ok, .msg.bad {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--tg-radius-sm);
  font-size: 12.5px;
  word-break: break-all;
}
.msg.ok { background: var(--tg-ok-soft); color: var(--tg-ok); border: 1px solid rgba(126, 231, 135, 0.25); }
.msg.bad { background: var(--tg-bad-soft); color: var(--tg-bad); border: 1px solid rgba(255, 107, 107, 0.25); }

/* ─────────────── asboblar qatori ─────────────── */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.toolbar .search {
  flex: 1 1 280px;
  max-width: 520px;
  padding-left: 36px;
  background-image: none;
}
.toolbar { position: relative; }
.toolbar::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 11px;
  width: 16px;
  height: 16px;
  background: var(--tg-dim);
  pointer-events: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.toolbar select { width: auto; min-width: 180px; }

/* tanlangan havolalar paneli */
.selection {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px 10px 16px;
  background: var(--tg-surface);
  border: 1px solid var(--tg-accent-line);
  border-radius: 12px;
  color: var(--tg-text);
  font-size: 13px;
}
.selection strong { font-family: var(--tg-mono); color: var(--tg-accent); font-weight: 600; margin-right: -4px; }
.selection input { flex: 1 1 260px; width: auto; height: 34px; margin-left: 6px; }

/* ─────────────── jadval ─────────────── */
.table-wrap {
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; }
thead th {
  background: var(--tg-surface);
  color: var(--tg-dim);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding-top: 11px;
  padding-bottom: 11px;
}
tbody td { border-top: 1px solid var(--tg-line); }
tbody tr { transition: background .15s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.num, th.num { text-align: right; }
td.num { font-family: var(--tg-mono); font-size: 13px; font-variant-numeric: tabular-nums; color: var(--tg-text); }
th.check, td.check { width: 44px; padding-right: 4px; }
td:last-child { text-align: right; }
td.muted { font-size: 12.5px; white-space: nowrap; }
td .muted { color: var(--tg-dim); }

.slug-cell { display: flex; align-items: center; gap: 8px; }
.slug-link {
  color: var(--tg-text);
  font-family: var(--tg-mono);
  font-size: 13px;
  text-decoration: underline;
  text-decoration-color: var(--tg-line-2);
  text-underline-offset: 3px;
  transition: color .15s, text-decoration-color .15s;
}
.slug-link:hover { color: var(--tg-accent); text-decoration-color: var(--tg-accent-line); }
a { color: var(--tg-text); text-decoration-color: var(--tg-line-2); }
a:hover { color: var(--tg-accent); }

/* chip: «nusxa» */
button.copy {
  height: 22px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: var(--tg-surface-3);
  color: #b9b9c0;
  font-size: 11.5px;
  font-weight: 500;
}
button.copy:hover { background: var(--tg-surface-3); color: var(--tg-accent); }

.target-cell {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tg-muted);
  font-size: 13px;
}

/* holat yorlig'i */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--tg-surface-3);
  color: #b9b9c0;
  font-size: 11.5px;
  font-weight: 500;
}
.badge.off { background: var(--tg-bad-soft); color: var(--tg-bad); }

/* bo'sh holat */
.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--tg-text);
  font-size: 16px;
  font-weight: 600;
}
.empty::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 12px;
  background: var(--tg-dim);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
}
table:has(+ .empty:not(.hidden)) thead th { border-bottom: 1px solid var(--tg-line); }

/* ─────────────── statistika oynasi ─────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}
.modal-box {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 24px 24px;
  background: var(--tg-surface-2);
  border: 1px solid var(--tg-line-2);
  border-radius: var(--tg-radius-lg);
  box-shadow: var(--tg-shadow);
}
button.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--tg-line-2);
  background: var(--tg-surface);
  color: var(--tg-muted);
  font-size: 20px;
  line-height: 1;
}
button.modal-close:hover { color: var(--tg-text); background: var(--tg-surface-3); }
.modal-box h2 {
  margin: 0 48px 4px 0;
  font-family: var(--tg-mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
#modal-body > .muted { font-size: 13px; word-break: break-all; margin-right: 48px; }

.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 18px 0 20px; }
.kv div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--tg-surface);
  border: 1px solid var(--tg-line);
  border-radius: 12px;
}
.kv div b {
  font-family: var(--tg-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--tg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kv div:last-child b { font-family: var(--tg-font); font-size: 16px; line-height: 30px; }
.kv div span, .modal-box h4 {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--tg-muted);
}
.modal-box h4 { margin: 0 0 10px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 128px;
  margin: 0 0 22px;
  padding: 14px 14px 0;
  background: var(--tg-surface);
  border: 1px solid var(--tg-line);
  border-radius: 12px;
  box-shadow: inset 0 -1px 0 var(--tg-line-2);
}
.chart > .muted { align-self: center; width: 100%; padding-bottom: 14px; text-align: center; font-size: 12.5px; }
.bar {
  flex: 1 1 0;
  max-width: 28px;
  min-height: 3px;
  background: var(--tg-accent);
  border-radius: 4px 4px 0 0;
  opacity: .85;
  transition: opacity .15s;
}
.bar:hover { opacity: 1; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px 20px; }
.split ul { list-style: none; margin: 0; padding: 0; }
.split li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--tg-line);
  font-size: 13px;
}
.split li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split li b { font-family: var(--tg-mono); font-weight: 500; font-size: 12.5px; }
.split li.muted { font-size: 12.5px; }

/* QR skanerlanishi uchun oq fon shart — bu yagona oq joy */
.qr-preview {
  display: block;
  width: 168px;
  height: 168px;
  margin: 22px auto 0;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
}
.modal-box [data-copy] { font-family: var(--tg-mono); font-size: 12.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* ─────────────── toast ─────────────── */
.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 22px;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: var(--tg-surface-2);
  border: 1px solid var(--tg-line-2);
  border-radius: 12px;
  box-shadow: var(--tg-shadow);
  color: var(--tg-text);
  font-size: 13px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }

/* ─────────────── moslashuv ─────────────── */
@media (max-width: 1000px) {
  .toolbar .search { flex-basis: 100%; max-width: none; }
  th, td { padding-left: 10px; padding-right: 10px; }
  th.check, td.check { width: 36px; padding-right: 2px; }
  .target-cell { max-width: 180px; }
}
@media (max-width: 640px) {
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  main { padding: 14px 12px 32px; }
  .topbar { flex-wrap: wrap; }
  .stats { order: 3; width: 100%; margin-left: 0; }
  .stat { flex: 1; justify-content: center; padding: 0 8px; }
  #logout { margin-left: auto; }
  .toolbar select { flex: 1 1 150px; min-width: 0; }
  .target-cell { max-width: 130px; }
  .modal { padding: 10px; }
  .modal-box { padding: 18px 16px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
