<!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/logo_flowsurgeon.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=Roboto:wght@400;500;600;700&display=swap" rel="stylesheet">
  <script src="{{ debug_route }}/_static/alpine.min.js" defer></script>
  <style>
    [x-cloak] { display: none !important; }
    *,
    *::before,
    *::after {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    /* ── Page fade-in ── */
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(6px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes cardIn {
      from { opacity: 0; transform: translateY(8px) scale(0.98); }
      to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    @keyframes slideDown {
      from { opacity: 0; transform: translateY(-4px); }
      to   { opacity: 1; transform: translateY(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;
      transition: color 0.15s ease;
    }

    /* ── Topbar ── */
    .topbar {
      height: 64px;
      background: #131720;
      display: flex;
      align-items: center;
      gap: 32px;
      padding: 0 32px;
      flex-shrink: 0;
      animation: slideDown 0.2s ease both;
    }

    .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;
      transition: color 0.15s ease;
    }

    .nav-item.inactive:hover span {
      color: #9CA3AF;
    }

    .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;
      animation: slideDown 0.2s ease 0.05s both;
    }

    .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;
      transition: color 0.15s ease;
    }

    .subnav-item.inactive:hover span {
      color: #9CA3AF;
    }

    .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;
      animation: fadeIn 0.2s ease both;
    }

    /* ── 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 {
      transition: background 0.12s ease;
    }

    .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;
      font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      color: #E5E7EB;
      outline: none;
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .filter-input:focus {
      border-color: #00D4AA;
      box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.12);
    }

    .filter-select {
      background: #131720;
      border: 1px solid #1E2328;
      border-radius: 8px;
      padding: 8px 14px;
      font-size: 13px;
      font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      color: #E5E7EB;
      outline: none;
      cursor: pointer;
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .filter-select:focus {
      border-color: #00D4AA;
      box-shadow: 0 0 0 2px rgba(0, 212, 170, 0.12);
    }

    .filter-btn {
      background: #00D4AA;
      color: #0D0F12;
      border: none;
      border-radius: 8px;
      padding: 8px 20px;
      font-size: 13px;
      font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.15s ease;
    }

    .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;
      transition: border-color 0.15s ease, color 0.15s ease;
    }

    .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;
    }

    /* ── Controls row ── */
    .controls-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-shrink: 0;
      gap: 12px;
    }

    /* ── Tab buttons ── */
    .tab-btns {
      display: flex;
      gap: 2px;
      align-items: center;
    }

    .tab-btn {
      display: flex;
      align-items: center;
      padding: 8px 16px;
      font-size: 13px;
      font-weight: 500;
      color: #6B7280;
      background: #131720;
      border-radius: 6px;
      text-decoration: none;
      transition: color 0.15s ease, background 0.15s ease;
    }

    .tab-btn:hover {
      color: #E5E7EB;
    }

    .tab-btn-active {
      color: #FFFFFF;
      font-weight: 600;
      background: #0D0F12;
      box-shadow: inset 0 -2px 0 #00D4AA;
    }

    /* ── Filter right ── */
    .filter-right {
      display: flex;
      gap: 8px;
      align-items: center;
      flex-shrink: 0;
    }

    .filter-label {
      font-size: 13px;
      color: #6B7280;
      white-space: nowrap;
    }

    /* ── Request card grid ── */
    .req-grid {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 12px;
      flex: 1;
      overflow-y: auto;
      align-content: start;
    }

    .req-card {
      background: #131720;
      border-radius: 10px;
      border: 1px solid #1E2328;
      padding: 14px 16px;
      display: flex;
      flex-direction: column;
      gap: 6px;
      text-decoration: none;
      cursor: pointer;
      transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
      animation: cardIn 0.2s ease both;
    }

    .req-card:hover {
      border-color: #2D3748;
      transform: translateY(-2px);
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    }

    .req-card-top {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    /* Card status: text color only (no badge background) */
    .cs-2xx { color: #C8D6E5; font-size: 18px; font-weight: 700; }
    .cs-3xx { color: #F59E0B; font-size: 18px; font-weight: 700; }
    .cs-4xx { color: #F59E0B; font-size: 18px; font-weight: 700; }
    .cs-5xx { color: #EF4444; font-size: 18px; font-weight: 700; }

    /* Card method: text color only */
    .cm-GET    { color: #60A5FA; font-size: 13px; font-weight: 600; }
    .cm-POST   { color: #C084FC; font-size: 13px; font-weight: 600; }
    .cm-PUT    { color: #C084FC; font-size: 13px; font-weight: 600; }
    .cm-PATCH  { color: #C084FC; font-size: 13px; font-weight: 600; }
    .cm-DELETE { color: #EF4444; font-size: 13px; font-weight: 600; }
    .cm-HEAD   { color: #9CA3AF; font-size: 13px; font-weight: 600; }
    .cm-OTHER  { color: #9CA3AF; font-size: 13px; font-weight: 600; }

    .req-path {
      font-size: 12px;
      color: #4B5563;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .req-dur {
      font-size: 13px;
      font-weight: 500;
    }

    .req-qinfo {
      font-size: 12px;
      color: #D4A017;
    }

    /* ── Staggered card animation ── */
    .req-card:nth-child(1)  { animation-delay: 0.03s; }
    .req-card:nth-child(2)  { animation-delay: 0.06s; }
    .req-card:nth-child(3)  { animation-delay: 0.09s; }
    .req-card:nth-child(4)  { animation-delay: 0.12s; }
    .req-card:nth-child(5)  { animation-delay: 0.15s; }
    .req-card:nth-child(6)  { animation-delay: 0.18s; }
    .req-card:nth-child(7)  { animation-delay: 0.21s; }
    .req-card:nth-child(8)  { animation-delay: 0.24s; }
    .req-card:nth-child(9)  { animation-delay: 0.27s; }
    .req-card:nth-child(10) { animation-delay: 0.30s; }
    .req-card:nth-child(11) { animation-delay: 0.33s; }
    .req-card:nth-child(12) { animation-delay: 0.36s; }

    /* ── Profiling placeholder ── */
    .profiling-placeholder {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 16px;
    }

    .profiling-title {
      font-size: 20px;
      font-weight: 600;
      color: #6B7280;
    }

    .profiling-sub {
      font-size: 14px;
      color: #4B5563;
    }

    /* ── Pagination row ── */
    .pagination-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-shrink: 0;
    }

    /* ── SPA layout helpers ── */
    .spa-wrapper {
      display: flex;
      flex-direction: column;
      gap: 24px;
      flex: 1;
      overflow: hidden;
      min-height: 0;
    }

    /* Flex-column wrapper for each tab panel */
    .tab-panel {
      display: flex;
      flex-direction: column;
      gap: 12px;
      flex: 1;
      overflow: hidden;
      min-height: 0;
    }

    /* ── Scrollbar ── */
    ::-webkit-scrollbar {
      width: 6px;
      height: 6px;
    }

    ::-webkit-scrollbar-track {
      background: transparent;
    }

    ::-webkit-scrollbar-thumb {
      background: #313244;
      border-radius: 3px;
    }
  </style>
</head>

<body {% block body_attrs %}{% endblock %}>
  {% block topbar %}{% endblock %}
  {% block subnav %}{% endblock %}
  <main class="content">
    {% block content %}{% endblock %}
  </main>
</body>

</html>