cortiq-gateway 0.2.13

Universal LLM gateway with intelligent routing and an embedded multilingual admin console
/* ===========================================================================
   allaigate Gateway Console — design system (build-free, no framework)
   Ported from cortiq-console, extended with light theme, charts, KPIs, modal.
   =========================================================================== */
:root,
:root[data-theme="dark"] {
  --bg: #0a0e1a;
  --bg-2: #0e1424;
  --panel: #131a2c;
  --card: #151d31;
  --card-2: #121a2c;
  --border: #243049;
  --border-soft: #1d2740;
  --text: #e6ecf7;
  --muted: #8b97b0;
  --faint: #5e6b85;
  --accent: #6366f1;
  --accent-2: #5eead4;
  --gold: #f59e0b;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --grid: #ffffff14;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --hover: #ffffff0a;
  --bg-grad: radial-gradient(1200px 700px at 80% -10%, #16203a 0%, var(--bg) 55%);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --card: #ffffff;
  --card-2: #f7f9fc;
  --border: #d8e0ee;
  --border-soft: #e6ebf4;
  --text: #0f172a;
  --muted: #5a6781;
  --faint: #8a96ad;
  --accent: #5457e6;
  --accent-2: #0ea5a4;
  --gold: #d97706;
  --good: #10b981;
  --warn: #d97706;
  --bad: #ef4444;
  --grid: #0f172a14;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --hover: #0f172a08;
  --bg-grad: radial-gradient(1200px 700px at 80% -10%, #e7edf9 0%, var(--bg) 55%);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg-grad);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 20px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 10px; }
code, .mono { font-family: var(--mono); }
.boot { padding: 60px; text-align: center; color: var(--faint); }

/* ---- layout -------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: 24px 32px 64px; max-width: 1220px; width: 100%; }

/* ---- brand + nav --------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand img { width: 30px; height: 30px; }
.brand b { font-size: 16px; }
.brand .sub { color: var(--muted); font-weight: 500; font-size: 13px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-weight: 500;
  border: 1px solid transparent; user-select: none;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.nav-item .ico { width: 18px; text-align: center; opacity: 0.95; font-size: 15px; }
.nav-spacer { flex: 1; }
.nav-foot { font-size: 11px; color: var(--faint); padding: 8px; }

/* ---- topbar -------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 32px; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px); z-index: 5;
}
.topbar .title { font-weight: 600; font-size: 15px; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  width: 34px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.lang-select {
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; font-weight: 600; width: auto;
}

/* ---- status pill --------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.dot.warn { background: var(--warn); }

/* ---- cards --------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card .card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card .card-head .sub { color: var(--muted); font-weight: 400; font-size: 13px; }
.card .card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } }

.page-head { margin-bottom: 20px; }
.page-head .flex { justify-content: space-between; align-items: flex-start; }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 74ch; }

/* ---- KPI ----------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 14px 16px;
}
.kpi .big { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.kpi .lbl { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* ---- forms --------------------------------------------------------------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px;
  font-family: inherit; font-size: 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; min-height: 64px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.inline { display: flex; align-items: center; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-bottom: 12px; }
.check input { width: auto; }
.hint { color: var(--faint); font-size: 12px; margin-top: 4px; }

/* "?" help badge — hover/focus shows the native title tooltip explaining a setting */
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1;
  cursor: help; vertical-align: middle; user-select: none;
  transition: 0.12s;
}
.help:hover, .help:focus { color: var(--accent); border-color: var(--accent); outline: none; }
label.field > span .help { text-transform: none; }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 16px; cursor: pointer;
  font-weight: 600; font-size: 14px; font-family: inherit; transition: 0.12s;
}
.btn:hover { border-color: var(--accent); background: var(--hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 85%, #fff), var(--gold)); border-color: var(--gold); color: #1a1206; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

/* ---- badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--muted);
}
.badge.tier-low, .badge.cheap, .badge.ok { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: color-mix(in srgb, var(--good) 8%, transparent); }
.badge.tier-medium, .badge.mid, .badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.badge.tier-high, .badge.expensive, .badge.bad, .badge.error { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.badge.router, .badge.store { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 40%, transparent); background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.badge.env { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ---- tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td .mono { font-size: 12.5px; color: var(--muted); }
tbody tr:hover td { background: var(--hover); }

/* ---- chips (routing) ----------------------------------------------------- */
.tierrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.tierrow:last-child { border-bottom: 0; }
.tierrow .tname { width: 110px; font-weight: 700; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 6px 5px 11px; font-weight: 600; font-size: 13px; }
.chip .ord { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.chip .arrow { cursor: pointer; color: var(--faint); padding: 0 1px; }
.chip .arrow:hover { color: var(--text); }
.chip .x { cursor: pointer; color: var(--faint); border-radius: 50%; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }
.chip .x:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* ---- toggle list (protocols) --------------------------------------------- */
.togglerow { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.togglerow:last-child { border-bottom: 0; }
.togglerow .meta { flex: 1; }
.togglerow .meta .name { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.togglerow .meta .desc { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: 0.15s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* ---- charts -------------------------------------------------------------- */
.chart { width: 100%; height: 180px; display: block; }
.chart .axis { stroke: var(--grid); stroke-width: 1; }
.chart .area { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .bar { fill: var(--accent); }
.barlist { display: flex; flex-direction: column; gap: 10px; }
.barlist .b { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.barlist .b .track { background: var(--bg-2); border-radius: 5px; height: 10px; overflow: hidden; }
.barlist .b .track > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.barlist .b .val { color: var(--muted); font-weight: 600; min-width: 56px; text-align: right; }

/* ---- playground ---------------------------------------------------------- */
.pg { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1024px) { .pg { grid-template-columns: 1fr; } }
.answer { white-space: pre-wrap; word-break: break-word; line-height: 1.55; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px; min-height: 120px; }
.routecard .kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.routecard .kv:last-child { border-bottom: 0; }
.routecard .kv .k { color: var(--muted); }
.routecard .kv .v { font-weight: 600; text-align: right; }
.scorebar { height: 7px; background: var(--bg-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.scorebar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

/* ---- modal --------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(3, 7, 18, 0.6); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; z-index: 40; overflow: auto; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; max-width: 560px; padding: 22px; }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ---- login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 30px; }
.login-card .brand { justify-content: center; padding-top: 0; }
.login-card h2 { text-align: center; }
.login-card p.sub { color: var(--muted); text-align: center; margin: 4px 0 22px; }

/* ---- misc ---------------------------------------------------------------- */
.empty { text-align: center; color: var(--faint); padding: 40px 20px; }
.spinner { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, var(--text) 25%, transparent); border-top-color: var(--text); border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; }
.muted { color: var(--muted); }
.right-align { text-align: right; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.seg button.active { background: var(--accent); color: #fff; }

/* ---- toasts -------------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast {
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); min-width: 220px;
  animation: slidein 0.18s ease; font-size: 13px;
}
.toast.good { border-left-color: var(--good); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- callout ------------------------------------------------------------- */
.callout { border: 1px solid var(--border); border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 6%, transparent); border-radius: 10px; padding: 13px 15px; color: var(--muted); margin-bottom: 16px; }
.callout.info { border-left-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 6%, transparent); }
.callout b { color: var(--text); }

/* ── Import model (HuggingFace → CMF) ── */
.view-head { margin-bottom: 14px; }
.view-head h2 { margin: 0 0 2px; }
.card-title { font-weight: 600; margin-bottom: 10px; }
.actions { margin-top: 12px; display: flex; gap: 8px; }
.pad { padding: 18px; }
.err { color: #e5534b; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

.hf-search {
  width: 100%; box-sizing: border-box; margin-bottom: 12px;
  padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--border, #2a2f3a); border-radius: 8px;
  background: var(--bg-2, #12151c); color: inherit;
}
.hf-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px; max-height: 420px; overflow-y: auto;
}
.hf-card {
  border: 1px solid var(--border, #2a2f3a); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; transition: border-color .12s, background .12s;
  background: var(--bg-2, #12151c);
}
.hf-card:hover { border-color: var(--accent, #5b8def); }
.hf-card.sel { border-color: var(--accent, #5b8def); background: rgba(91,141,239,.10); }
.hf-id { font-weight: 600; font-size: 13px; word-break: break-all; margin-bottom: 6px; }
.hf-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.badge.bad { background: rgba(229,83,75,.15); color: #e5534b; }

.import-form { margin-top: 14px; }
.adv { margin-top: 8px; }
.adv-body { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border, #2a2f3a); }

.pbar {
  height: 8px; border-radius: 6px; overflow: hidden; margin: 10px 0;
  background: var(--bg-2, #12151c); border: 1px solid var(--border, #2a2f3a);
}
.pbar-fill { height: 100%; width: 100%; border-radius: 6px; }
.pbar-fill.run {
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--accent, #5b8def), transparent);
  animation: pbar-slide 1.2s infinite ease-in-out;
}
.pbar-fill.ok { background: #3fb950; }
.pbar-fill.err { background: #e5534b; }
@keyframes pbar-slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

.conv-log {
  margin-top: 10px; max-height: 260px; overflow-y: auto;
  background: var(--bg-2, #0d1017); border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px; padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; color: var(--muted, #9aa4b2);
}

/* Router-key field: input grows, inline "Save key" button sits beside it */
.key-row { display: flex; gap: 8px; align-items: stretch; }
.key-row input { flex: 1 1 auto; min-width: 0; }
.key-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* Determinate progress fill (known %); .run remains the indeterminate slider */
.pbar-fill.det {
  background: linear-gradient(90deg, var(--accent, #5b8def), #7aa2f7);
  transition: width .4s ease;
}
/* Import job cards (multiple conversions, live) */
.job { padding: 12px 0; border-top: 1px solid var(--border-soft, #232833); }
.job:first-of-type { border-top: 0; }
.job-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.job-head b { word-break: break-all; }
.small { font-size: 12px; }
/* Router usage: readable, wrapping key/value rows (no horizontal overflow) */
.usage-box { max-width: 100%; overflow-x: hidden; }
.mono.kv { display: flex; gap: 6px; padding: 1px 0; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.mono.kv .kv-k { color: var(--muted, #9aa4b2); flex: 0 0 auto; }
.mono.kv .kv-v { font-weight: 600; overflow-wrap: anywhere; word-break: break-word; min-width: 0; }