:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --border: #e4e3de;
  --border-strong: #cfcdc6;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --side: #111214;
  --side-text: #c9c8c2;
  --side-active: #23252a;
  --good: #0d7a3a; --good-soft: #e3f4e9;
  --warn: #9a6200; --warn-soft: #fdf2dc;
  --bad: #c62b2a;  --bad-soft: #fbe6e5;
  --grid: #ecebe6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111111; --surface: #1a1a19; --surface-2: #212120; --border: #2e2e2c; --border-strong: #42423f;
    --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #3987e5; --accent-soft: #1b2b40;
    --side: #0b0b0b; --side-active: #1f2023;
    --good: #4cc27a; --good-soft: #15291d; --warn: #e0a53a; --warn-soft: #2e2413; --bad: #ef6b6a; --bad-soft: #341a1a;
    --grid: #292927;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111; --surface: #1a1a19; --surface-2: #212120; --border: #2e2e2c; --border-strong: #42423f;
  --text: #ffffff; --text-2: #c3c2b7; --text-3: #8f8e86;
  --accent: #3987e5; --accent-soft: #1b2b40;
  --side: #0b0b0b; --side-active: #1f2023;
  --good: #4cc27a; --good-soft: #15291d; --warn: #e0a53a; --warn-soft: #2e2413; --bad: #ef6b6a; --bad-soft: #341a1a;
  --grid: #292927;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin: 18px 0 16px; }
.login-card .brand { color: var(--text); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px; }

label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 12px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-err { color: var(--bad); font-size: 13px; min-height: 20px; margin: 0 0 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); padding: 0 14px; height: 36px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; }
.btn.wide { width: 100%; height: 40px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; padding: 0 8px 18px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--side-text); text-decoration: none; padding: 9px 10px; border-radius: 8px; font-weight: 500; }
.side nav a svg { width: 18px; height: 18px; opacity: .8; }
.side nav a:hover { background: var(--side-active); color: #fff; }
.side nav a.active { background: var(--side-active); color: #fff; }
.side nav a.active svg { color: #6da7ec; opacity: 1; }
.side-foot { border-top: 1px solid #25272b; padding: 12px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot .btn { color: var(--side-text); }
.side-foot .btn:hover { background: var(--side-active); }
.me { font-size: 12px; line-height: 1.35; min-width: 0; }
.me b { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; flex: 1; }
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); padding: 4px; cursor: pointer; }
.menu-btn svg { width: 22px; height: 22px; }
.content { padding: 24px 28px 48px; max-width: 1280px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; margin: 0; }
.card-h .sub { color: var(--text-3); font-size: 12px; }
.card-b { padding: 16px 20px 20px; }
.muted { color: var(--text-3); }
.hint { color: var(--text-2); font-size: 13px; margin: 0 0 14px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .k { color: var(--text-2); font-size: 13px; font-weight: 500; }
.tile .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .d { color: var(--text-3); font-size: 12px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 500; border: 0; background: none; color: var(--text-2); padding: 0 12px; height: 30px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters input, .filters select { width: auto; margin: 0; min-height: 36px; padding: 6px 10px; }
.filters .grow { flex: 1; min-width: 180px; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.r, th.r { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.tbl-wrap td:first-child { white-space: nowrap; }
td .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.empty { text-align: center; color: var(--text-3); padding: 36px 12px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge svg { width: 12px; height: 12px; stroke-width: 2.4; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; stroke: none; }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .ax { fill: var(--text-3); stroke: none; font-size: 11px; font-family: inherit; }
.chart .ln { fill: none; stroke-width: 2; }
.chart .hair { stroke: var(--border-strong); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 170px; z-index: 3; }
.tip b { display: block; margin-bottom: 4px; }
.tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 64px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { height: 14px; background: var(--surface-2); border-radius: 4px; position: relative; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.grid2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 20px; }

/* Split */
.golink { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 12px; }
.golink code { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-list { display: flex; flex-direction: column; }
.split-item { display: grid; grid-template-columns: auto 1fr 110px 120px; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.split-item:last-child { border-bottom: 0; }
.split-item .nm b { display: block; }
.split-item .nm a { font-size: 12px; color: var(--text-3); text-decoration: none; }
.split-item .share { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.split-item .share small { display: block; color: var(--text-3); font-weight: 400; font-size: 12px; }
.split-item input[type=number] { margin: 0; width: 100%; text-align: right; }
.split-item.off .nm, .split-item.off .share { opacity: .45; }
.pct-wrap { position: relative; }
.pct-wrap::after { content: '%'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.pct-wrap input { padding-right: 26px; }

.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 99px; transition: .15s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled { cursor: default; }

.savebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.savebar .sum { font-size: 13px; color: var(--text-2); }
.savebar .sum.bad { color: var(--bad); font-weight: 600; }
.win { color: var(--good); font-weight: 600; }

/* Matn tahrirlash */
.ed-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.ed-bar .sp { flex: 1; }
.ed-count { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.ed-count b { color: var(--warn); }
.ed-stage { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; display: flex; justify-content: center; }
.ed-stage iframe { border: 0; width: 100%; height: calc(100vh - 230px); min-height: 480px; background: #fff; display: block; }
.ed-stage.phone { padding: 16px 0; }
.ed-stage.phone iframe { width: 390px; max-width: 100%; border-radius: 18px; box-shadow: 0 0 0 8px #1b1c1f, 0 10px 30px rgba(0,0,0,.25); }
.ed-hint { font-size: 12px; color: var(--text-3); margin: 10px 2px 0; }
.chg-list { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.chg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.chg .o { color: var(--text-3); text-decoration: line-through; }
.chg .n { color: var(--text); font-weight: 500; margin-top: 2px; }
.dlg.wide { width: min(720px, calc(100vw - 32px)); }
.ver { border-bottom: 1px solid var(--border); padding: 12px 0; }
.ver:last-child { border-bottom: 0; }
.ver-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ver-h .t { font-weight: 600; }
.ver-h .sp { flex: 1; }
.ver details { margin-top: 6px; }
.ver summary { cursor: pointer; font-size: 12px; color: var(--accent); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: auto; min-height: 0; margin: 3px 0 0; }
.check small { display: block; color: var(--text-3); font-weight: 400; }

/* Status */
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.up { background: var(--good); }
.dot.down { background: var(--bad); }
.dot.unk { background: var(--text-3); }

/* Dialog */
.dlg { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg form { padding: 22px; }
.dlg h3 { margin: 0 0 16px; font-size: 17px; }
.dlg .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg p { color: var(--text-2); margin: 0 0 14px; }
.pw-show { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.pw-show code { flex: 1; font-size: 15px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: #111; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--bad); }

.details { font-size: 12px; color: var(--text-2); max-width: 520px; }
.details .kv { display: block; }
.details .kv b { color: var(--text); font-weight: 600; }
.nowrap { white-space: nowrap; }
.loading { color: var(--text-3); padding: 40px 0; text-align: center; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .menu-btn { display: block; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .card-h { padding: 14px 16px 0; }
  .card-b { padding: 14px 16px 16px; }
  .tile .v { font-size: 22px; }
  .bar-row { grid-template-columns: 110px 1fr 52px; }
  .split-item { grid-template-columns: auto 1fr 90px; }
  .split-item .share { grid-column: 2 / -1; text-align: left; }
  .filters .seg { overflow-x: auto; max-width: 100%; }
}

/* Vizual muharrir asboblari */
.ed-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 46px; padding: 8px 12px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.ed-tools .ed-el { margin-right: 4px; }
.ed-tools .num-in { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 12px; color: var(--text-3); }
.ed-tools .num-in input { width: 74px; min-height: 30px; margin: 0; padding: 4px 6px; }
.ed-tools input[type=color] { width: 38px; min-height: 30px; padding: 2px; margin: 0; }
.ed-tools select { width: auto; min-height: 30px; margin: 0; padding: 4px 6px; }
.ed-tools .seg button { height: 26px; }
.ed-tools .tsep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.ed-stage { position: relative; }
.ed-stage iframe { height: auto; min-height: 0; }
.ed-stage:not(.phone) { display: block; }

#edSite { max-width: 100%; overflow-x: auto; }

.ed-tools .font-ctl { display: inline-flex; align-items: center; gap: 4px; }
.ed-tools .font-ctl input { width: 58px; min-height: 30px; margin: 0; padding: 4px 6px; text-align: center; }
.chg .n, .chg .o { white-space: pre-wrap; }
@media (max-width: 820px) {
  table.px tr { display: block; border-bottom: 1px solid var(--border); }
  table.px td { display: block; border: 0; padding: 6px 12px; }
  table.px td:first-child { padding-bottom: 0; }
}
