/* apka V Algo Engine — modern shell (loaded only on engine.apkav.in, on top of flow's style.css) */
:root[data-theme="dark"] {
  --bg: #0b0e14; --panel: #121722; --panel2: #171d2a; --ink: #e8ecf3; --quiet: #8b95a7; --edge: #222a39; --grid: #1a2030;
  --acc: #7c5cff; --acc2: #22d3ee; --good: #22c55e; --bad: #f43f5e; --warn: #f59e0b; --glow: 0 10px 30px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --panel: #ffffff; --panel2: #f7f8fc; --ink: #0f172a; --quiet: #64748b; --edge: #e3e8f2; --grid: #eef1f7;
  --acc: #6d4aff; --acc2: #0891b2; --good: #16a34a; --bad: #e11d48; --warn: #d97706; --glow: 0 8px 24px rgba(15, 23, 42, .07);
}
html, body { background: var(--bg); color: var(--ink); }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
.ae { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.ae-side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; background: var(--panel); border-right: 1px solid var(--edge); }
.ae-brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px; }
.ae-brand b { display: block; font-size: 15px; letter-spacing: .2px; } .ae-brand small { color: var(--quiet); font-size: 11.5px; }
.ae-logo { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: linear-gradient(135deg, var(--acc), var(--acc2)); color: #fff; font-size: 17px; }
.ae-nav { display: flex; flex-direction: column; gap: 4px; }
.ae-nav a, .ae-tabs a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--quiet); text-decoration: none; font-weight: 550; font-size: 14px; transition: background .15s, color .15s; }
.ae-nav a svg, .ae-tabs a svg { width: 19px; height: 19px; flex: none; }
.ae-nav a:hover { background: var(--panel2); color: var(--ink); }
.ae-nav a.on { background: color-mix(in srgb, var(--acc) 14%, transparent); color: var(--acc); }
.ae-side-foot { margin-top: auto; padding: 8px; font-size: 12.5px; } .ae-side-foot a { color: var(--quiet); text-decoration: none; }
.ae-main { min-width: 0; display: flex; flex-direction: column; }
.ae-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 14px 26px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--edge); }
.ae-top h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.2px; } .ae-top .sp { flex: 1; }
.ae-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--panel2); border: 1px solid var(--edge); color: var(--quiet); cursor: pointer; }
.ae-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--quiet); }
.ae-pill.on { color: var(--good); } .ae-pill.on i { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 22%, transparent); }
.ae-pill.live { color: #fff; background: var(--bad); border-color: var(--bad); } .ae-pill.live i { background: #fff; }
#subnav { padding: 14px 26px 0; } #main { padding: 18px 26px 90px; max-width: 1400px; width: 100%; box-sizing: border-box; }
.ae-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; }
.ae-seg a { padding: 7px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--quiet); text-decoration: none; }
.ae-seg a.on { background: var(--acc); color: #fff; }
.ae-tabs { display: none; }
.ae .card, .ae-card { background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; box-shadow: var(--glow); }
.ae-card { padding: 18px 20px; margin-bottom: 16px; }
.ae-card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.ae-card-h > div { display: flex; align-items: center; gap: 10px; }
.ae-card h3, .ae-card-h h3 { margin: 0; font-size: 15.5px; font-weight: 700; } .ae-sub { margin: 18px 0 8px; font-size: 13px; color: var(--quiet); text-transform: uppercase; letter-spacing: .6px; }
.ae-link { font-size: 13px; color: var(--acc); text-decoration: none; font-weight: 600; }
.ae-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .ae-grid2 > .ae-card { margin-bottom: 0; } .ae-grid2 { margin-bottom: 16px; }
.ae-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.ae-kpi { background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 16px 18px; box-shadow: var(--glow); display: flex; flex-direction: column; gap: 4px; }
.ae-kpi span { font-size: 12px; color: var(--quiet); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.ae-kpi b { font-size: 26px; font-weight: 750; letter-spacing: -.5px; } .ae-kpi b small { font-size: 15px; color: var(--quiet); } .ae-kpi > small { color: var(--quiet); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up { color: var(--good); } .dn { color: var(--bad); } .warn { color: var(--warn); }
.ae-chips { display: flex; flex-wrap: wrap; gap: 6px; } .ae-chips button { border: 1px solid var(--edge); background: var(--panel2); color: var(--quiet); border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 600; cursor: pointer; }
.ae-chips button.on { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.ae-feed { max-height: 62vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.ae-msg { border: 1px solid var(--edge); border-radius: 12px; padding: 10px 12px; background: var(--panel2); } .ae-msg.fail { border-color: color-mix(in srgb, var(--bad) 50%, var(--edge)); }
.ae-msg-h { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; } .ae-msg-h time { font-size: 12px; color: var(--quiet); margin-left: auto; }
.ae-msg-b { white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; word-break: break-word; }
.ae-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--acc) 15%, transparent); color: var(--acc); text-transform: uppercase; letter-spacing: .4px; }
.ae-empty { padding: 26px; text-align: center; color: var(--quiet); font-size: 13.5px; border: 1px dashed var(--edge); border-radius: 12px; }
.ae-mini-log { margin-top: 12px; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 220px; overflow: auto; border: 1px solid var(--edge); border-radius: 12px; padding: 10px; background: var(--panel2); }
.ae-mini-log.tall { max-height: 320px; } .ae-mini-log div { padding: 2px 0; } .ae-mini-log time { color: var(--quiet); margin-right: 8px; }
.ae-tw { overflow-x: auto; } .ae-t { width: 100%; border-collapse: collapse; font-size: 13.5px; } .ae-t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--quiet); padding: 6px 8px; border-bottom: 1px solid var(--edge); }
.ae-t td { padding: 9px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; } .ae-t .r { text-align: right; }
.ae-st { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--edge); }
.ae-st.open, .ae-st.sending { color: var(--acc2); } .ae-st.closed { color: var(--good); } .ae-st.error { color: var(--bad); } .ae-st.closing { color: var(--warn); }
/* switches & fields */
.sw { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; } .sw input { opacity: 0; width: 0; height: 0; }
.sw i { position: absolute; inset: 0; border-radius: 999px; background: var(--edge); transition: .2s; cursor: pointer; }
.sw i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: .2s; }
.sw input:checked + i { background: var(--good); } .sw input:checked + i::after { transform: translateX(18px); }
.ae-f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--quiet); font-weight: 600; }
.ae-f.wide { margin-bottom: 12px; } .ae-f .small { font-weight: 500; }
.ae input[type=text], .ae input[type=number], .ae input[type=time], .ae input[type=password], .ae select {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px; font-size: 14px; outline: none; transition: border .15s, box-shadow .15s; }
.ae input:focus, .ae select:focus { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 22%, transparent); }
.ae .btn { border-radius: 10px; padding: 8px 14px; font-weight: 650; }
.ae .btn.pri { background: var(--acc); border-color: var(--acc); color: #fff; }
.ae-segc { display: inline-flex; padding: 3px; gap: 3px; border-radius: 11px; background: var(--panel2); border: 1px solid var(--edge); }
.ae-segc button { border: 0; background: transparent; color: var(--quiet); padding: 7px 14px; border-radius: 8px; font-weight: 650; cursor: pointer; font-size: 13px; }
.ae-segc button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); } .ae-segc button.on.live { background: var(--bad); color: #fff; }
.ae-hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; border-left: 4px solid var(--edge); }
.ae-hero.on { border-left-color: var(--good); } .ae-hero.live { border-left-color: var(--bad); }
.ae-hero-l { display: flex; gap: 14px; align-items: center; } .ae-hero h2 { margin: 0; font-size: 18px; } .ae-hero p { margin: 3px 0 0; color: var(--quiet); font-size: 13px; }
.ae-hero-r { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; } .ae-hero-r input[type=number] { width: 80px; }
.ae-open { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-color: color-mix(in srgb, var(--acc2) 45%, var(--edge)); }
.ae-algos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; } .ae-algos .ae-card { margin: 0; }
.ae-algo { opacity: .78; transition: opacity .2s; } .ae-algo.on { opacity: 1; border-top: 3px solid var(--acc); }
.ae-num { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; background: color-mix(in srgb, var(--acc) 16%, transparent); color: var(--acc); }
.ae-chk { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--grid); cursor: pointer; } .ae-chk:first-child { border-top: 0; }
.ae-chk input { margin-top: 3px; accent-color: var(--acc); width: 16px; height: 16px; } .ae-chk b { display: block; font-size: 13.5px; } .ae-chk small { color: var(--quiet); font-size: 12px; }
.ae-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--grid); }
.ae-row:first-of-type { border-top: 0; } .ae-row b { display: block; font-size: 13.5px; } .ae-row small { display: block; color: var(--quiet); font-size: 12px; }
.ae-row-r { display: flex; gap: 10px; align-items: center; }
.ae-win { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--grid); font-size: 13px; } .ae-win b { min-width: 96px; }
.ae-m { display: inline-block; min-width: 46px; text-align: center; padding: 2px 6px; border-radius: 6px; background: var(--panel2); font-size: 12px; }
.ae-m.u { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); } .ae-m.d { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.ae-savebar { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 18px; border-radius: 14px;
  background: var(--ink); color: var(--panel); box-shadow: 0 12px 40px rgba(0, 0, 0, .35); transition: transform .25s; z-index: 50; font-weight: 600; font-size: 13.5px; }
.ae-savebar.show { transform: translate(-50%, 0); } .ae-savebar .btn:not(.pri) { background: transparent; color: var(--panel); border-color: color-mix(in srgb, var(--panel) 35%, transparent); }
.ae-form .ae-actions { display: flex; gap: 10px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; } .dot.ok { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 20%, transparent); }
.dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.login { background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--acc) 25%, transparent), transparent), var(--bg); }
.login .card { border-radius: 18px; }
@media (max-width: 1100px) { .ae-algos { grid-template-columns: 1fr; } .ae-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) {
  .ae { grid-template-columns: 1fr; } .ae-side { display: none; }
  .ae-top { padding: 12px 16px; } .ae-top h1 { font-size: 17px; } #subnav { padding: 12px 16px 0; } #main { padding: 14px 16px 100px; }
  .ae-grid2 { grid-template-columns: 1fr; }
  .ae-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--edge); }
  .ae-tabs a { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 10.5px; flex: 1; }
  .ae-tabs a.on { color: var(--acc); }
  .ae-savebar { bottom: 78px; }
  .ae-hero-r { width: 100%; }
}

/* status badge (LIVE / problems) — pill like the engine button, instant states */
.ae-top .badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .3px;
  background: var(--panel2); border: 1px solid var(--edge); color: var(--quiet); text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.ae-top .badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.ae-top .badge.live { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--edge)); }
.ae-top .badge.live .dot { animation: aeBeat 1.6s ease-out infinite; }
@keyframes aeBeat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }
.ae-top .badge.bad, .ae-top .tg-badge.bad { color: #fff; background: var(--bad); border-color: var(--bad); animation: aeAlarm 1s ease-in-out infinite; }
.ae-top .badge.warn { color: #111; background: var(--warn); border-color: var(--warn); }
@keyframes aeAlarm { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--bad) 30%, transparent); } }

.ae-logo.bull { background: linear-gradient(160deg, #1d2536, #0e131c); border: 1px solid rgba(232,199,122,.35); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); overflow: hidden; } .ae-logo.bull svg { width: 26px; height: 26px; display: block; }

/* collapsible sidebar (icons only) */
.ae { transition: grid-template-columns .2s ease; }
.ae-head-toggle { margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--edge); background: var(--panel2); color: var(--quiet); border-radius: 8px; cursor: pointer; flex: none; padding: 0; }
.ae-head-toggle:hover { color: var(--ink); border-color: color-mix(in srgb, var(--acc) 40%, var(--edge)); }
.ae-head-toggle svg { width: 16px; height: 16px; }
.ae-collapse { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--edge); background: var(--panel2); color: var(--quiet);
  border-radius: 10px; cursor: pointer; font: 600 13.5px/1 inherit; font-family: inherit; width: 100%; box-sizing: border-box; }
.ae-collapse:hover { color: var(--ink); border-color: color-mix(in srgb, var(--acc) 40%, var(--edge)); }
.ae-collapse svg { width: 19px; height: 19px; flex: none; transition: transform .2s; }
.ae-side-foot { margin-top: auto; padding: 8px; font-size: 12.5px; }
.ae-side-foot a { display: flex; align-items: center; gap: 9px; color: var(--quiet); text-decoration: none; padding: 6px 8px; border-radius: 8px; }
.ae-side-foot a:hover { color: var(--ink); background: var(--panel2); }
.ae-side-foot a svg { width: 17px; height: 17px; flex: none; }
.ae.mini { grid-template-columns: 74px 1fr; }
.ae.mini .ae-side { padding: 18px 10px; align-items: center; }
.ae.mini .ae-brand { padding: 4px 0; justify-content: center; }
.ae.mini .ae-brand > div, .ae.mini .ae-head-toggle, .ae.mini .ae-nav a span, .ae.mini .ae-collapse span, .ae.mini .ae-side-foot a span { display: none; }
.ae.mini .ae-nav { align-items: center; width: 100%; }
.ae.mini .ae-nav a { justify-content: center; padding: 11px; width: 46px; box-sizing: border-box; }
.ae.mini .ae-collapse { padding: 11px; width: 46px; justify-content: center; }
.ae.mini .ae-collapse svg { transform: rotate(180deg); }
.ae.mini .ae-side-foot { padding: 4px 0; }
.ae.mini .ae-side-foot a { justify-content: center; padding: 10px; width: 46px; box-sizing: border-box; }
@media (max-width: 860px) { .ae-collapse, .ae-head-toggle { display: none; } .ae.mini { grid-template-columns: 1fr; } }

.ae-nav { overflow: visible; } .ae.mini .ae-nav { padding: 0; }   /* kill base nav{overflow-x:auto} scrollbar in icon mode */
