<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>{% block title %}psyc cockpit{% endblock %}</title>
  <link rel="icon" type="image/png" href="/static/psyc-logo.png">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="/static/cockpit.css">
  <link rel="stylesheet" href="/static/psyc-tokens.css">
</head>
<body class="{% block body_class %}{% endblock %}">
  <header class="topbar">
    <a class="brand" href="/cases">
      <img class="brand-icon" src="/static/psyc-logo.png" alt="psyc">
      <span class="brand-sub">operations cockpit</span>
    </a>
    <nav class="nav">
      <a href="/cases">Cases</a>
      <a href="/lookup">Lookup</a>
      <a href="/response">Response</a>
      <a href="/queue">Queue</a>
      <a href="/ledger">Ledger</a>
      <a href="/train">Trainline</a>
      {% if request.session.get('admin_who') %}
      <a href="/admin" class="nav-admin" title="Admin control center">
        <svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" style="vertical-align:-2px;">
          <path d="M12 2 L20 5 V12 C20 17 16.5 20.5 12 22 C7.5 20.5 4 17 4 12 V5 Z"
                fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>
          <circle cx="12" cy="11" r="2.4" fill="none" stroke="currentColor" stroke-width="1.8"/>
          <rect x="11" y="12.5" width="2" height="4" rx="1" fill="currentColor"/>
        </svg>
        Admin
      </a>
      {% endif %}
    </nav>
    {% if request.session.get('admin_who') %}
    <span class="admin-chip" title="Admin session · click to manage">
      <a href="/admin" class="admin-chip-body">
        <span class="admin-chip-dot"></span>
        <span class="admin-chip-label">ADMIN · {{ request.session.get('admin_who') }}</span>
      </a>
      <a href="/admin/logout" class="admin-chip-lock" title="Lock the admin zone (sign out)" aria-label="lock">⏻</a>
    </span>
    {% endif %}
    <span class="model-status" id="model-status" data-state="checking" title="checking…">
      <span class="model-status-dot"></span><span class="model-status-text">model</span>
    </span>
    <div class="family">
      <img class="family-icon" src="/static/nn-sc-icon.png" alt="NN-sc — Security/Control" title="NN-sc · Security — psyc, the security app of the neuronetz platform">
    </div>
  </header>
  <main class="content">
    {% block content %}{% endblock %}
  </main>
  <footer class="footer">psyc 0.1 — defensive CTI prototype · powered by <a href="https://neuronetz.ai" target="_blank" rel="noopener">neuronetz.ai</a></footer>
  <script>
    fetch('/api/inference-status').then(r => r.json()).then(s => {
      const el = document.getElementById('model-status');
      if (!el) return;
      if (s.online) {
        el.dataset.state = 'online';
        el.title = 'model up · ' + s.adapter;
        el.querySelector('.model-status-text').textContent = 'model · live';
      } else {
        el.dataset.state = 'offline';
        el.title = 'inference server unreachable — Classifier bot falls back to rules';
        el.querySelector('.model-status-text').textContent = 'model · offline';
      }
    }).catch(() => {});
  </script>
</body>
</html>
