<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{% block title %}FlowSurgeon{% endblock %}</title>
  <link rel="icon" type="image/png" href="{{ debug_route }}/_static/Icon.png">
  <style>
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    body {
      font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      background: #0D0F12;
      color: #E5E7EB;
      height: 100vh;
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    a { color: inherit; text-decoration: none; }

    /* ── Topbar ── */
    .topbar {
      height: 64px;
      background: #131720;
      display: flex;
      align-items: center;
      gap: 32px;
      padding: 0 32px;
      flex-shrink: 0;
    }
    .logo { font-size: 20px; font-weight: 700; color: #00D4AA; }

    .nav-item {
      height: 64px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      position: relative;
      text-decoration: none;
    }
    .nav-item span { font-size: 14px; }
    .nav-item.active span  { color: #FFFFFF; font-weight: 600; }
    .nav-item.inactive span { color: #6B7280; }
    .nav-underline {
      position: absolute;
      bottom: 0; left: 0; right: 0;
      height: 3px;
      border-radius: 2px 2px 0 0;
      background: #00D4AA;
    }

    /* ── Breadcrumb topbar ── */
    .breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 14px; }
    .breadcrumb .sep   { color: #4B5563; }
    .breadcrumb .b-dim { color: #6B7280; }
    .breadcrumb .b-mid { color: #E5E7EB; font-weight: 500; }
    .breadcrumb .b-cur { color: #00D4AA; font-weight: 500; }

    /* ── Sub-nav ── */
    .subnav {
      height: 48px;
      background: #131720;
      display: flex;
      align-items: center;
      padding: 0 48px;
      border-top: 1px solid #1E2328;
      flex-shrink: 0;
    }
    .subnav-item {
      height: 48px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 0 20px;
      position: relative;
      text-decoration: none;
    }
    .subnav-item span { font-size: 13px; }
    .subnav-item.active span   { color: #FFFFFF; font-weight: 600; }
    .subnav-item.inactive span { color: #6B7280; }
    .subnav-underline {
      position: absolute;
      bottom: 0; left: 0; right: 0;
      height: 3px;
      border-radius: 2px 2px 0 0;
      background: #00D4AA;
    }

    /* ── Content ── */
    .content {
      padding: 32px 48px;
      display: flex;
      flex-direction: column;
      gap: 24px;
      flex: 1;
      overflow: hidden;
    }

    /* ── Section header ── */
    .section-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-shrink: 0;
    }
    .section-title { font-size: 28px; font-weight: 700; color: #FFFFFF; }
    .stat-badge {
      display: flex; align-items: center; gap: 8px;
      background: #161A22; border-radius: 8px; padding: 6px 14px;
    }
    .stat-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; }
    .stat-badge span { font-size: 12px; font-weight: 500; color: #9CA3AF; }

    /* ── Table ── */
    .table-wrap {
      background: #131720;
      border-radius: 12px;
      overflow: hidden;
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
    }
    .tbl-head {
      height: 48px;
      background: #0D1117;
      display: flex;
      align-items: center;
      padding: 0 24px;
      flex-shrink: 0;
    }
    .tbl-body { overflow-y: auto; flex: 1; }
    .th {
      font-size: 11px; font-weight: 600;
      color: #6B7280; letter-spacing: 1px;
    }
    .tr {
      height: 52px;
      display: flex;
      align-items: center;
      padding: 0 24px;
    }
    .tr-req { height: 48px; }
    .tr:hover { background: #161A22; }
    .sep { height: 1px; background: #1E2328; }
    .td { font-size: 13px; color: #E5E7EB; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .td-dim { font-size: 12px; color: #6B7280; }
    .td-link:hover { color: #00D4AA; }

    /* ── Column widths ── */
    .w-70  { flex: 0 0 70px; }
    .w-80  { flex: 0 0 80px; }
    .w-90  { flex: 0 0 90px; }
    .w-100 { flex: 0 0 100px; }
    .w-110 { flex: 0 0 110px; }
    .w-120 { flex: 0 0 120px; }
    .w-160 { flex: 0 0 160px; }
    .w-fill { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* ── Method badge ── */
    .method {
      display: inline-flex; align-items: center; justify-content: center;
      border-radius: 4px; padding: 3px 10px;
      font-size: 11px; font-weight: 700;
    }
    .m-GET    { background: #0D3B2E; color: #10B981; }
    .m-POST   { background: #2D1B0E; color: #F59E0B; }
    .m-PUT    { background: #2D1B0E; color: #F59E0B; }
    .m-PATCH  { background: #2D1B0E; color: #F59E0B; }
    .m-DELETE { background: #3B0D0D; color: #EF4444; }
    .m-HEAD   { background: #161A22; color: #9CA3AF; }
    .m-OTHER  { background: #161A22; color: #9CA3AF; }

    /* ── Status badge ── */
    .status {
      display: inline-flex; align-items: center; justify-content: center;
      border-radius: 4px; padding: 3px 10px;
      font-size: 11px; font-weight: 700;
    }
    .s-2xx { background: #0D3B2E; color: #10B981; }
    .s-3xx { background: #2D1B0E; color: #F59E0B; }
    .s-4xx { background: #2D1B0E; color: #F59E0B; }
    .s-5xx { background: #3B0D0D; color: #EF4444; }
    .s-err { background: #3B0D0D; color: #EF4444; }

    /* ── Duration color ── */
    .dur-fast   { color: #10B981; font-weight: 600; }
    .dur-medium { color: #F59E0B; font-weight: 600; }
    .dur-slow   { color: #EF4444; font-weight: 600; }

    /* ── Stat cards (detail) ── */
    .cards-row { display: flex; gap: 16px; flex-shrink: 0; }
    .card {
      flex: 1;
      background: #131720; border-radius: 12px;
      padding: 20px;
      display: flex; flex-direction: column; gap: 8px;
    }
    .card-label {
      font-size: 11px; font-weight: 600;
      color: #6B7280; letter-spacing: 1px; text-transform: uppercase;
    }
    .card-value { font-size: 24px; font-weight: 700; }
    .card-badge {
      display: inline-flex; align-items: center;
      border-radius: 6px; padding: 4px 12px;
    }
    .card-badge span { font-size: 16px; font-weight: 700; }

    /* ── Detail panels ── */
    .panels-row {
      display: flex; gap: 16px; flex: 1; min-height: 0; overflow: hidden;
    }
    .panel-card {
      flex: 1; background: #131720; border-radius: 12px;
      overflow: hidden; display: flex; flex-direction: column;
    }
    .panel-hd {
      background: #0D1117; padding: 14px 20px;
      display: flex; justify-content: space-between; align-items: center;
      flex-shrink: 0;
    }
    .panel-hd-title { font-size: 14px; font-weight: 600; color: #FFFFFF; }
    .panel-bd {
      padding: 20px; overflow-y: auto; flex: 1;
      display: flex; flex-direction: column; gap: 12px;
    }
    .field { display: flex; flex-direction: column; gap: 4px; }
    .field-lbl { font-size: 11px; font-weight: 600; color: #6B7280; }
    .field-val { font-size: 13px; color: #E5E7EB; }
    .code-block {
      background: #0D1117; border-radius: 8px; padding: 12px;
      display: flex; flex-direction: column; gap: 4px;
    }
    .code-line {
      font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
      font-size: 12px; color: #9CA3AF;
      white-space: pre-wrap; word-break: break-all;
    }
    .code-line.err { color: #EF4444; }
    .psep { height: 1px; background: #1E2328; }

    /* ── SQL query list ── */
    .query-item {
      padding: 16px 0; border-bottom: 1px solid #1E2328;
    }
    .query-item:last-child { border-bottom: none; }
    .query-meta { display: flex; align-items: center; gap: 8px; }
    .query-num { font-size: 11px; color: #6B7280; font-weight: 600; min-width: 28px; }
    .query-sql {
      font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
      font-size: 12px; color: #E5E7EB;
      background: #0D1117; border-radius: 6px;
      padding: 10px 12px; margin-top: 8px;
      white-space: pre-wrap; word-break: break-all;
    }
    .query-detail { display: flex; gap: 16px; font-size: 12px; color: #9CA3AF; margin-top: 6px; }
    .badge-slow { background: #3B0D0D; color: #EF4444; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
    .badge-dup  { background: #2D1B0E; color: #F59E0B; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 700; }

    /* ── Traceback ── */
    .traceback {
      background: #0D1117; border-radius: 8px; padding: 16px;
      font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
      font-size: 12px; color: #9CA3AF;
      white-space: pre-wrap; word-break: break-all;
      line-height: 1.6; overflow-y: auto; flex: 1;
    }

    /* ── Filter bar ── */
    .filter-bar { display: flex; gap: 10px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
    .filter-input {
      background: #131720; border: 1px solid #1E2328; border-radius: 8px;
      padding: 8px 14px; font-size: 13px; color: #E5E7EB; outline: none;
    }
    .filter-input:focus { border-color: #00D4AA; }
    .filter-select {
      background: #131720; border: 1px solid #1E2328; border-radius: 8px;
      padding: 8px 14px; font-size: 13px; color: #E5E7EB; outline: none; cursor: pointer;
    }
    .filter-select:focus { border-color: #00D4AA; }
    .filter-btn {
      background: #00D4AA; color: #0D0F12; border: none; border-radius: 8px;
      padding: 8px 20px; font-size: 13px; font-weight: 600; cursor: pointer;
    }
    .filter-btn:hover { background: #00BFA0; }
    .filter-clear { font-size: 13px; color: #6B7280; }
    .filter-clear:hover { color: #9CA3AF; }

    /* ── Pagination ── */
    .pagination { display: flex; justify-content: center; align-items: center; gap: 8px; flex-shrink: 0; padding: 8px 0; }
    .page-btn {
      background: #131720; border: 1px solid #1E2328; border-radius: 6px;
      padding: 6px 14px; font-size: 13px; color: #E5E7EB; text-decoration: none;
    }
    .page-btn:hover { border-color: #00D4AA; color: #00D4AA; }
    .page-info { font-size: 13px; color: #6B7280; }

    /* ── Sort header link ── */
    .th-link { color: #6B7280; text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: 1px; }
    .th-link:hover { color: #E5E7EB; }
    .th-link.active { color: #00D4AA; }

    /* ── Empty state ── */
    .empty { padding: 48px; text-align: center; color: #6B7280; font-size: 14px; }

    /* ── Scrollbar ── */
    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: transparent; }
    ::-webkit-scrollbar-thumb { background: #313244; border-radius: 3px; }
  </style>
</head>
<body>
  {% block topbar %}{% endblock %}
  {% block subnav %}{% endblock %}
  <main class="content">
    {% block content %}{% endblock %}
  </main>
</body>
</html>
