/* Вкладка агентов. Токены те же, что у дашборда: фон #000/#0a0a0a, линии #1a1a1a/#2a2a2a,
   акцент Omegna #3fae9d, рост #00c758, падение #fb2c36. */
:root {
  --ag-bg: #000;
  --ag-panel: #0a0a0a;
  --ag-panel-2: #111;
  --ag-line: #1a1a1a;
  --ag-line-2: #2a2a2a;
  --ag-text: #fafafa;
  --ag-muted: #9ca3af;
  --ag-dim: #6a7282;
  --ag-accent: #3fae9d;
  --ag-accent-hover: #2f9c91;
  --ag-up: #00c758;
  --ag-down: #fb2c36;
  --ag-mono: "Geist Mono", "Geist Mono Fallback", ui-monospace, monospace;
}

body { background: var(--ag-bg); color: var(--ag-text); }
.ag-wrap { max-width: 1600px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .ag-wrap { padding: 0 24px; } }

/* полоса статистики */
.ag-statbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; padding-bottom: 12px; }
.ag-stats { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ag-stats > div { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ag-k { color: var(--ag-muted); font-size: 14px; }
.ag-v { font-weight: 500; }
.ag-accent { color: var(--ag-accent); }
.ag-note { color: var(--ag-dim); font-size: 12px; }
@media (max-width: 767px) { .ag-hide-md { display: none !important; } }
@media (max-width: 639px) { .ag-hide-sm { display: none !important; } }

/* кнопки */
.ag-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer; border: 1px solid transparent; transition: background-color .15s, border-color .15s, transform .1s; white-space: nowrap; }
.ag-btn:active { transform: scale(.98); }
.ag-btn-accent { background: var(--ag-accent); color: #000; }
.ag-btn-accent:hover { background: var(--ag-accent-hover); }
.ag-btn-ghost { background: var(--ag-line); color: var(--ag-text); border-color: var(--ag-line-2); }
.ag-btn-ghost:hover { background: #222; border-color: #3a3a3a; }
.ag-btn-danger { background: transparent; color: var(--ag-down); border-color: rgba(251, 44, 54, .35); }
.ag-btn-danger:hover { background: rgba(251, 44, 54, .08); }
.ag-btn:disabled { opacity: .45; cursor: not-allowed; }
.ag-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

/* вкладки */
.ag-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.ag-tab { position: relative; padding: 12px 16px; font-size: 14px; font-weight: 500; color: var(--ag-dim); white-space: nowrap; background: none; border: 0; cursor: pointer; }
.ag-tab:hover { color: #d1d5db; }
.ag-tab.is-active { color: #fff; }
.ag-tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: #fff; }
.ag-count { display: inline-flex; min-width: 20px; height: 18px; padding: 0 6px; margin-left: 6px; align-items: center; justify-content: center; border-radius: 9px; background: var(--ag-line-2); color: var(--ag-text); font-size: 11px; font-family: var(--ag-mono); }

/* вступление */
.ag-intro { padding: 28px 0 8px; max-width: 760px; }
.ag-intro h1 { font-size: clamp(24px, 3.2vw, 34px); line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.ag-intro h1 span { color: var(--ag-accent); }
.ag-intro p { margin-top: 10px; color: var(--ag-muted); font-size: 15px; line-height: 1.55; }

/* сетка карточек */
.ag-grid { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 20px 0; }
@media (min-width: 768px) { .ag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .ag-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.ag-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; background: var(--ag-panel); border: 1px solid var(--ag-line); border-radius: 16px; transition: border-color .15s; min-width: 0; }
.ag-card:hover { border-color: var(--ag-line-2); }
.ag-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ag-icon { --tone: #3fae9d; flex: none; width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; color: var(--tone);
  background: #0d0d0e; border: 1px solid #232427; }
.ag-icon-lg { width: 56px; height: 56px; border-radius: 14px; }
.ag-icon-sm { width: 30px; height: 30px; border-radius: 8px; }
.ag-iconpick { display: flex; gap: 14px; align-items: center; }
.ag-glyphs { display: grid; grid-template-columns: repeat(8, 42px); gap: 6px; }
@media (max-width: 520px) { .ag-glyphs { grid-template-columns: repeat(6, 40px); } .ag-iconpick { align-items: flex-start; } }
.ag-glyphs button { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; color: var(--ag-muted); background: transparent; border: 1px solid var(--ag-line-2); cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.ag-glyphs button:hover { color: #fff; }
.ag-glyphs button.is-on { color: var(--tone); border-color: var(--tone); background: #0d0d0e; }
.ag-tones { display: flex; gap: 8px; margin-top: 4px; }
.ag-tones button { width: 22px; height: 22px; border-radius: 50%; background: var(--tone); border: 2px solid transparent; outline: 1px solid transparent; cursor: pointer; }
.ag-tones button.is-on { border-color: var(--ag-panel); outline-color: var(--tone); }
.ag-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.ag-badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.ag-badge-auto { background: rgba(63, 174, 157, .12); color: var(--ag-accent); border: 1px solid rgba(63, 174, 157, .3); }
.ag-badge-co { background: rgba(255, 255, 255, .06); color: #d1d5db; border: 1px solid var(--ag-line-2); }
.ag-badge-run { background: rgba(0, 199, 88, .1); color: var(--ag-up); border: 1px solid rgba(0, 199, 88, .3); }
.ag-badge-pause { background: rgba(255, 255, 255, .05); color: var(--ag-muted); border: 1px solid var(--ag-line-2); }
.ag-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ag-engine { font-size: 12px; color: var(--ag-dim); font-family: var(--ag-mono); }
.ag-tagline { color: var(--ag-muted); font-size: 14px; line-height: 1.5; min-height: 42px; }

.ag-perf { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ag-big { font-family: var(--ag-mono); font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.ag-big small { display: block; margin-top: 6px; font-family: inherit; font-size: 12px; font-weight: 400; color: var(--ag-dim); letter-spacing: 0; }
.ag-up { color: var(--ag-up); }
.ag-down { color: var(--ag-down); }
.ag-spark { flex: 1; max-width: 170px; height: 48px; }

.ag-kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--ag-line); }
.ag-kv div { min-width: 0; }
.ag-kv dt { font-size: 11px; color: var(--ag-dim); text-transform: uppercase; letter-spacing: .05em; }
.ag-kv dd { margin-top: 3px; font-family: var(--ag-mono); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-chip { height: 24px; padding: 0 9px; display: inline-flex; align-items: center; border-radius: 8px; background: var(--ag-line); border: 1px solid var(--ag-line-2); font-size: 12px; color: #d1d5db; white-space: nowrap; }
.ag-actions { display: flex; gap: 8px; margin-top: auto; }
.ag-actions .ag-btn { flex: 1; }

.ag-sig { display: flex; flex-direction: column; gap: 6px; }
.ag-sig-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-family: var(--ag-mono); color: #d1d5db; }
.ag-sig-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-side { font-weight: 600; }

.ag-compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; font-family: var(--ag-mono); }
.ag-compare b { font-size: 22px; font-weight: 600; }
.ag-compare .ag-arrow { color: var(--ag-dim); }
.ag-compare small { display: block; color: var(--ag-dim); font-family: var(--font-sans, inherit); font-size: 11px; margin-top: 2px; }

.ag-empty { grid-column: 1 / -1; padding: 48px 24px; text-align: center; border: 1px dashed var(--ag-line-2); border-radius: 16px; color: var(--ag-muted); }
.ag-empty h3 { color: var(--ag-text); font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.ag-empty .ag-btn { margin-top: 16px; }

.ag-foot { color: var(--ag-dim); font-size: 12px; line-height: 1.6; padding: 8px 0 24px; max-width: 900px; }

/* как это работает */
.ag-how { display: grid; gap: 16px; padding: 20px 0; grid-template-columns: 1fr; }
@media (min-width: 900px) { .ag-how { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ag-how article { padding: 20px; border: 1px solid var(--ag-line); border-radius: 16px; background: var(--ag-panel); }
.ag-how h3 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.ag-how p, .ag-how li { color: var(--ag-muted); font-size: 14px; line-height: 1.6; }
.ag-how ul { margin-top: 6px; padding-left: 18px; list-style: disc; }
.ag-how .ag-step { font-family: var(--ag-mono); color: var(--ag-accent); font-size: 12px; margin-bottom: 6px; display: block; }

/* шторка с деталями */
.ag-drawer, .ag-modal { position: fixed; inset: 0; z-index: 80; }
.ag-drawer[hidden], .ag-modal[hidden] { display: none; }
.ag-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .65); backdrop-filter: blur(4px); }
.ag-drawer-body { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--ag-panel); border-left: 1px solid var(--ag-line-2); overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; animation: ag-slide .2s ease-out; }
@keyframes ag-slide { from { transform: translateX(24px); opacity: 0; } }
.ag-dhead { display: flex; align-items: center; gap: 12px; }
.ag-dhead .ag-x { margin-left: auto; }
.ag-x { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--ag-line); border: 1px solid var(--ag-line-2); color: var(--ag-muted); cursor: pointer; flex: none; }
.ag-x:hover { color: #fff; }
.ag-box { border: 1px solid var(--ag-line); border-radius: 14px; padding: 16px; background: var(--ag-bg); }
.ag-box h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ag-dim); margin-bottom: 12px; font-weight: 500; }
.ag-chart { width: 100%; height: 200px; display: block; }
.ag-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ag-table th { text-align: left; font-weight: 500; color: var(--ag-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 8px 0; }
.ag-table td { padding: 8px 8px 8px 0; border-top: 1px solid var(--ag-line); font-family: var(--ag-mono); white-space: nowrap; }
.ag-table-wrap { overflow-x: auto; }
.ag-config { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.ag-config div { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--ag-line); padding-bottom: 8px; }
.ag-config span:first-child { color: var(--ag-dim); }
.ag-config span:last-child { font-family: var(--ag-mono); text-align: right; }
@media (max-width: 520px) { .ag-config { grid-template-columns: 1fr; } .ag-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* мастер деплоя */
.ag-modal-body { position: absolute; inset: 0; margin: auto; width: min(1180px, 100%); height: min(860px, 100%); background: var(--ag-panel); border: 1px solid var(--ag-line-2); border-radius: 18px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); overflow: hidden; animation: ag-pop .18s ease-out; }
@keyframes ag-pop { from { transform: scale(.985); opacity: 0; } }
@media (max-width: 760px) { .ag-modal-body { border-radius: 0; border: 0; } }
.ag-mhead { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--ag-line); }
.ag-mhead h2 { font-size: 18px; font-weight: 600; }
.ag-mhead p { color: var(--ag-dim); font-size: 13px; }
.ag-mhead .ag-x { margin-left: auto; }
.ag-mbody { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; min-width: 0; }
@media (min-width: 980px) { .ag-mbody { grid-template-columns: 200px minmax(0, 1fr) 340px; } }
.ag-steps { display: none; border-right: 1px solid var(--ag-line); padding: 12px; overflow-y: auto; }
@media (min-width: 980px) { .ag-steps { display: block; } }
.ag-steps a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: 14px; color: var(--ag-muted); text-decoration: none; }
.ag-steps a:hover { background: var(--ag-line); color: #fff; }
.ag-steps a.is-on { background: var(--ag-line); color: #fff; }
.ag-steps a i { font-style: normal; font-family: var(--ag-mono); font-size: 11px; color: var(--ag-dim); width: 18px; }
.ag-form { overflow-y: auto; padding: 20px; scroll-behavior: smooth; min-height: 0; }
.ag-sec { padding-bottom: 28px; margin-bottom: 28px; border-bottom: 1px solid var(--ag-line); }
.ag-sec:last-child { border-bottom: 0; }
.ag-sec > h3 { font-size: 16px; font-weight: 600; }
.ag-sec > p { color: var(--ag-dim); font-size: 13px; margin-top: 4px; margin-bottom: 16px; }
.ag-fields { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) { .ag-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ag-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ag-field.is-wide { grid-column: 1 / -1; }
.ag-field > label, .ag-label { font-size: 13px; color: #d1d5db; display: flex; justify-content: space-between; gap: 8px; }
.ag-field > label output, .ag-label output { font-family: var(--ag-mono); color: var(--ag-accent); }
.ag-hint { font-size: 12px; color: var(--ag-dim); line-height: 1.45; }
.ag-live { display: inline-block; margin-left: 6px; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--ag-dim); border: 1px solid var(--ag-line-2); border-radius: 6px; padding: 1px 5px; vertical-align: 1px; }
.ag-input, .ag-select, .ag-textarea { width: 100%; background: transparent; border: 1px solid var(--ag-line-2); border-radius: 10px; color: var(--ag-text); font-size: 14px; padding: 10px 12px; outline: none; transition: border-color .15s; }
.ag-input:focus, .ag-select:focus, .ag-textarea:focus { border-color: var(--ag-accent); }
.ag-select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #9ca3af 50%), linear-gradient(135deg, #9ca3af 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.ag-select option { background: #111; }
.ag-textarea { min-height: 110px; resize: vertical; line-height: 1.5; font-family: inherit; }
.ag-input-wrap { position: relative; }
.ag-input-wrap .ag-input { padding-right: 52px; font-family: var(--ag-mono); }
.ag-input-wrap span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--ag-dim); }
input[type="range"].ag-range { width: 100%; accent-color: var(--ag-accent); height: 20px; }
.ag-seg { display: flex; gap: 4px; background: var(--ag-line); border-radius: 12px; padding: 4px; }
.ag-seg button { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--ag-muted); background: none; border: 0; cursor: pointer; text-align: center; }
.ag-seg button small { display: block; font-size: 11px; font-weight: 400; color: var(--ag-dim); margin-top: 2px; }
.ag-seg button.is-on { background: var(--ag-accent); color: #000; }
.ag-seg button.is-on small { color: rgba(0, 0, 0, .65); }
.ag-tpl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 1100px) { .ag-tpl { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ag-tpl button { text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--ag-line-2); background: transparent; color: var(--ag-text); cursor: pointer; min-width: 0; }
.ag-tpl button b { display: block; font-size: 14px; font-weight: 600; }
.ag-tpl button span { display: block; font-size: 12px; color: var(--ag-dim); margin-top: 4px; line-height: 1.4; }
.ag-tpl button.is-on { border-color: var(--ag-accent); background: rgba(63, 174, 157, .08); }
.ag-switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13px; color: #d1d5db; }
.ag-switch input { appearance: none; flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--ag-line-2); position: relative; cursor: pointer; transition: background .15s; margin-top: 1px; }
.ag-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.ag-switch input:checked { background: var(--ag-accent); }
.ag-switch input:checked::after { transform: translateX(14px); }
.ag-markets { max-height: 260px; overflow-y: auto; border: 1px solid var(--ag-line-2); border-radius: 12px; }
.ag-mrow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--ag-line); font-size: 13px; cursor: pointer; }
.ag-mrow:first-child { border-top: 0; }
.ag-mrow:hover { background: var(--ag-panel-2); }
.ag-mrow img { width: 22px; height: 22px; border-radius: 50%; background: var(--ag-line-2); flex: none; object-fit: cover; }
.ag-mrow .ag-mvol { margin-left: auto; font-family: var(--ag-mono); color: var(--ag-dim); }
.ag-mrow input { accent-color: var(--ag-accent); }
.ag-preview { display: none; border-left: 1px solid var(--ag-line); padding: 20px; overflow-y: auto; background: var(--ag-bg); }
@media (min-width: 980px) { .ag-preview { display: flex; flex-direction: column; gap: 14px; } }
.ag-preview h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ag-dim); font-weight: 500; }
.ag-preview .ag-chart { height: 150px; }
.ag-pstats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ag-pstats div { border: 1px solid var(--ag-line); border-radius: 12px; padding: 10px 12px; }
.ag-pstats dt { font-size: 11px; color: var(--ag-dim); text-transform: uppercase; letter-spacing: .05em; }
.ag-pstats dd { margin-top: 4px; font-family: var(--ag-mono); font-size: 18px; }
.ag-mfoot { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--ag-line); }
.ag-mfoot .ag-msum { color: var(--ag-muted); font-size: 13px; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-mfoot .ag-msum b { color: var(--ag-text); font-family: var(--ag-mono); font-weight: 500; }
.ag-mfoot .ag-msum b.ag-up { color: var(--ag-up); }
.ag-mfoot .ag-msum b.ag-down { color: var(--ag-down); }
@media (max-width: 560px) {
  .ag-mfoot { flex-wrap: wrap; }
  .ag-mfoot .ag-msum { flex: 1 0 100%; white-space: normal; }
  .ag-mfoot [data-close] { display: none; }
  .ag-mfoot #wDeploy { flex: 1; }
  .ag-mhead p { display: none; }
}
.ag-mini-preview { display: block; }
@media (min-width: 980px) { .ag-mini-preview { display: none; } }
.ag-err { color: var(--ag-down); font-size: 12px; }

/* тост */
.ag-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 120; padding: 12px 16px; border-radius: 12px; background: #111; border: 1px solid var(--ag-line-2); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); }
.ag-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* шапка: подсветка вкладки едет под Agents */
#navPill { transition: left .2s ease-out, width .2s ease-out, opacity .2s; }
@media (prefers-reduced-motion: reduce) { .ag-drawer-body, .ag-modal-body { animation: none; } #navPill { transition: none; } }
