:root {
  --bg: #17151f; --panel: #1f1c2b; --panel2: #272338; --line: #353049;
  --text: #e8e6f0; --muted: #9a95ad; --accent: #8b5cf6; --accent2: #6d3fe0;
  --green: #2f7d4a; --green2: #3d9a5c; --yellow: #7d6a2f; --orange: #8a4f2a; --red: #7a2f36; --red2: #5a222a;
  --up: #5fd38a; --down: #f26a6a;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--down); }
.spacer { flex: 1; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.ghost { background: transparent; }
.icon { background: transparent; border: 0; color: var(--text); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon:hover { background: var(--panel2); }
.input { background: #13111a; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; width: 100%; }
.input.sm { width: auto; padding: 6px 8px; }
.input:focus { outline: none; border-color: var(--accent); }
label { display: block; color: var(--muted); margin: 10px 0; }
label .input { margin-top: 4px; color: var(--text); }
label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* вход */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.card { background: var(--panel); border: 1px solid var(--line); padding: 24px; border-radius: 10px; width: 320px; display: grid; gap: 12px; }
.card h2 { margin: 0; }

/* раскладка */
.app { display: grid; grid-template-columns: 300px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.logo { font-weight: 700; font-size: 20px; color: var(--accent); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.toolbar { display: flex; padding: 8px; gap: 4px; border-bottom: 1px solid var(--line); }
.list-head { display: flex; justify-content: space-between; padding: 8px 12px; font-weight: 600; background: var(--panel2); }
.list-head b { color: var(--accent); }
.projects { list-style: none; margin: 0; padding: 4px; overflow: auto; flex: 1; }
.projects li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.projects li:hover { background: var(--panel2); }
.projects li.active { background: var(--accent); color: #fff; font-weight: 600; }
.projects li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.projects li .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.projects li .dot.running, .projects li .dot.pending { background: #f2c94c; }
.projects li .dot.done { background: var(--up); }
.sidebar > .input { margin: 8px; width: auto; }

.main { overflow: auto; padding: 14px 18px; min-width: 0; display: flex; flex-direction: column; }
.main > section { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.empty { margin: auto; color: var(--muted); font-size: 18px; }
.phead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.phead h1 { margin: 0; font-size: 26px; color: var(--accent); text-transform: uppercase; }

.summary { display: grid; grid-template-columns: 240px 1fr; gap: 14px; margin-top: 12px; }
.buckets { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.buckets .input { width: 100%; margin-bottom: 8px; }
.buckets div div { padding: 2px 0; }
.b3 { color: #5fd38a; } .b5 { color: #e0973a; } .b10 { color: #b49cf7; } .b20 { color: #f26a6a; } .b50 { color: #5aa7e6; } .b100 { color: #c5865e; }
.chartbox { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; height: 220px; position: relative; }

.kpis { display: flex; gap: 0; margin: 12px 0; border: 1px solid var(--line); border-radius: 8px; width: fit-content; overflow: hidden; }
.kpi { padding: 6px 14px; border-right: 1px solid var(--line); background: var(--panel); }
.kpi:last-child { border-right: 0; }
.kpi small { color: var(--muted); display: block; }
.kpi b { font-size: 20px; }
.up { color: var(--up); } .down { color: var(--down); }

.tbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.tbar label { margin: 0; }
.tablewrap { overflow: auto; flex: 1; min-height: 300px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; }
#tbl th { position: sticky; top: 0; background: var(--panel2); z-index: 2; padding: 8px 10px; text-align: right; white-space: nowrap; cursor: pointer; user-select: none; }
#tbl th.l, #tbl td.l { text-align: left; }
#tbl th.sticky, #tbl td.sticky { position: sticky; left: 0; z-index: 1; background: var(--panel); }
#tbl th.sticky { z-index: 3; background: var(--panel2); }
#tbl td { padding: 6px 10px; border-bottom: 1px solid #241f33; text-align: right; white-space: nowrap; }
#tbl td.phrase { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
#tbl td.url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
#tbl td.url a { color: var(--muted); }
#tbl tr:hover td { filter: brightness(1.15); }
.p3 { background: var(--green2); } .p10 { background: var(--green); } .p30 { background: var(--yellow); }
.p100 { background: var(--orange); } .pout { background: var(--red); } .perr { color: #f2994a; } .pnone { color: var(--muted); }
.delta { font-size: 11px; margin-right: 4px; }
.delta.up { color: #b6f5cb; } .delta.down { color: #ffb3b3; }
td.ws { background: #2a2140; }
.statusbar { display: flex; gap: 24px; padding: 8px 4px; color: var(--muted); flex-wrap: wrap; }

/* диалоги */
.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(760px, 95vw); }
.dlg.wide { width: min(1100px, 95vw); }
.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #312a7a; font-weight: 700; font-size: 18px; }
.dlg-body { padding: 14px 16px; min-height: 340px; }
.dlg-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 16px; background: var(--panel2); }
.dlg-foot .err { margin-right: auto; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); }
.tab { background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; padding: 8px 14px; cursor: pointer; font: inherit; }
.tab.active { background: var(--panel); color: var(--text); }
.tabpane { display: none; } .tabpane.active { display: block; }
textarea.input { resize: vertical; }
.seg { display: flex; gap: 16px; } .seg label { display: inline-flex; gap: 6px; color: var(--text); }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 4px 6px 4px 12px; display: flex; gap: 6px; align-items: center; }
.chips li button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.file { display: inline-block; margin-top: 8px; }
.dash td, .dash th { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.dash a { color: var(--accent); cursor: pointer; }
.bar { height: 8px; background: #13111a; border-radius: 4px; width: 140px; display: inline-block; vertical-align: middle; margin-left: 8px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.plan { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 12px 0 6px; line-height: 1.6; color: var(--text); }
#freqState.busy::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f2c94c; margin-right: 6px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
/* Вебмастер */
.ya { background: #fc3f1d; color: #fff; border-radius: 50%; display: inline-block; width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: 12px; font-weight: 700; }
.btn.yellow { background: #d9a520; border-color: #d9a520; color: #1b1410; }
.btn.danger { background: #d9534f; border-color: #d9534f; color: #fff; }
.btn.sm { padding: 4px 10px; }
.wm { position: fixed; top: 52px; left: 0; right: 0; bottom: 0; background: var(--bg); display: grid; grid-template-columns: 380px 1fr; gap: 14px; padding: 14px; z-index: 20; }
.wm-side, .wm-main { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; min-height: 0; }
.wm-side { display: flex; flex-direction: column; padding: 14px; }
.wm-main { padding: 14px 18px; overflow: auto; position: relative; display: flex; flex-direction: column; }
.wm-main > #wmHost { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.wm-main > #wmHost.hidden { display: none; }
.wm-close { position: absolute; right: 10px; top: 8px; z-index: 2; }
.wm-title { font-size: 22px; margin-bottom: 10px; } .wm-title .g { color: #5fd38a; } .wm-title .r { color: #fc3f1d; } .wm-title .o { color: #e0973a; }
.wm-tools .input { flex: 1; }
.wm-head, .wm-hosts li { display: grid; grid-template-columns: 1fr 70px 50px; gap: 6px; align-items: center; }
.wm-head { padding: 10px 8px 6px; font-weight: 600; } .wm-head b { color: var(--down); } .wm-head span:not(:first-child) { text-align: right; }
.wm-hosts { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.wm-hosts li { padding: 8px; border-radius: 10px; cursor: pointer; }
.wm-hosts li:hover { background: var(--panel2); } .wm-hosts li.active { background: #2f2b45; }
.wm-hosts li span:not(:first-child) { text-align: right; }
.wm-hosts small { display: block; color: var(--muted); font-size: 11px; } .wm-hosts small.bad { color: #f2994a; }
.wm-url { margin: 0; color: #5fd38a; font-size: 24px; }
.wm-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.wm-cards div { background: var(--panel2); border-radius: 6px; padding: 6px 8px; } .wm-cards small { color: var(--muted); display: block; }
.wm-tabs .tabbtn.active { background: #2f7d4a; border-color: #3d9a5c; }
#wmTbl th { position: sticky; top: 0; background: var(--panel2); z-index: 2; padding: 8px 10px; text-align: right; white-space: nowrap; cursor: pointer; }
#wmTbl th.l, #wmTbl td.l { text-align: left; }
#wmTbl td { padding: 6px 10px; border-bottom: 1px solid #241f33; text-align: right; white-space: nowrap; }
#wmTbl td.txt { max-width: 360px; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--panel); z-index: 1; }
#wmTbl th.txt { position: sticky; left: 0; z-index: 3; }
#wmTbl td.txt a { color: #6aa8f0; text-decoration: none; }
#wmTbl sup { font-size: 10px; margin-right: 3px; } sup.up { color: #b6f5cb; } sup.down { color: #ffb3b3; }
.wm-acc { display: grid; grid-template-columns: 1fr 220px; gap: 12px; }
.wm-acc-list { list-style: none; margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: 8px; min-height: 220px; background: #13111a; }
.wm-acc-list li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.wm-acc-list li.active { background: var(--accent); color: #fff; }
.wm-acc-btns { display: grid; gap: 8px; align-content: start; } .wm-acc-btns .btn { text-align: center; text-decoration: none; }
@media (max-width: 900px) { .wm { grid-template-columns: 1fr; overflow: auto; } .wm-side { max-height: 300px; } .wm-acc { grid-template-columns: 1fr; } }
.card .input { margin-bottom: 8px; }
.logo.center { text-align: center; margin-bottom: 6px; }
.authtabs { display: flex; gap: 4px; margin-bottom: 6px; } .authtabs .tab { flex: 1; border-radius: 6px; border-bottom: 1px solid var(--line); }
.card form { display: grid; } .small { font-size: 12px; }
.banner { background: #3a2f12; border: 1px solid #7d6a2f; color: #f2d98a; padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.banner a { color: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row.end { justify-content: flex-end; margin-top: 12px; } .row.end .err { margin-right: auto; }
.saved { font-size: 12px; color: var(--up); margin-left: 6px; }
.dash.admin select, .dash.admin input { background: #13111a; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; }
.dash.admin tr.pending td { background: #2e2610; }
.usage { display: grid; gap: 10px; margin-top: 10px; } .usage .bar { width: 220px; }
td.cl { max-width: 220px; overflow: hidden; text-overflow: ellipsis; text-align: left !important; color: #b49cf7; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.center-link { text-align: center; color: var(--muted); margin-top: 6px; }
.note-ok { color: var(--up); }
.dlg a { color: #b49cf7; }
.reasons { margin: 10px 0; padding: 8px 12px; background: #2a1a1e; border: 1px solid #5a222a; border-radius: 8px; font-size: 13px; }
.reasons div { margin-top: 3px; word-break: break-word; }
.chip { background: var(--panel2); border: 1px solid var(--accent); border-radius: 14px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.chk-modes { display: grid; gap: 6px; margin: 10px 0; } .chk-modes label { margin: 0; color: var(--text); }
.chk-balance { margin: 8px 0; font-size: 15px; } .chk-balance b { font-size: 18px; }
.chk-balance .low { color: var(--down); }
.progress { position: relative; height: 26px; background: #13111a; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; margin: 6px 0 12px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; }
.chk-stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.chk-stat div { background: var(--panel2); border-radius: 8px; padding: 8px 10px; } .chk-stat small { display: block; color: var(--muted); } .chk-stat b { font-size: 18px; }
.toast { z-index: 100; position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--accent); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 420px; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 52px auto 1fr; }
  .sidebar { max-height: 240px; }
  .summary { grid-template-columns: 1fr; }
}
