/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --muted:       #64748b;
  --primary:     #1e293b;
  --accent:      #2563eb;
  --accent-dim:  #eff6ff;
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --amber:       #d97706;
  --amber-bg:    #fffbeb;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --radius:      6px;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:   0 20px 60px rgba(0,0,0,.18);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.site-header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.2px;
}
.site-header .tagline {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}
.site-header .gen-ts {
  font-size: 11px;
  color: #475569;
  text-align: right;
  white-space: nowrap;
}

/* ── Stats strip ────────────────────────────────────────────────────────── */
.stats-strip {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 9px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.stat { display: flex; align-items: baseline; gap: 5px; }
.stat strong { font-size: 16px; font-weight: 700; color: var(--text); line-height: 1; }
.stats-chips { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 9px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.search-wrap {
  position: relative;
  max-width: 360px;
  flex: 1;
}
.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  line-height: 1;
  font-size: 13px;
}
#search {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #dbeafe;
}
.filter-count { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Table wrapper ──────────────────────────────────────────────────────── */
.table-outer {
  flex: 1;
  overflow-x: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ── Table ──────────────────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead { position: sticky; top: 0; z-index: 6; }

/* Header rows */
.th-group-row th {
  background: #0f172a;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-right: 1px solid #1e293b;
  text-align: center;
}
.th-group-row .g-workload { text-align: left; }

th {
  background: #1e293b;
  color: #cbd5e1;
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border-right: 1px solid #334155;
  transition: background .1s;
}
th:last-child { border-right: none; }
th:hover:not(.no-sort) { background: #263348; }
th.sorted-asc::after  { content: " ↑"; opacity: .75; }
th.sorted-desc::after { content: " ↓"; opacity: .75; }
th.no-sort            { cursor: default; }
th.th-metric          { background: #1a3050; text-align: center; }
th.th-metric:hover    { background: #1f3a5f; }

/* Body rows */
td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f8fafc;
  vertical-align: middle;
  white-space: nowrap;
}
tr:nth-child(even) td { background: #f8fafc; }
tr:hover td            { background: var(--accent-dim) !important; }
td:last-child          { border-right: none; }

/* Workload cell */
.wl-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
}
.wl-name {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11.5px;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-name a { color: inherit; text-decoration: none; }
.wl-name a:hover { text-decoration: underline; }

/* Info button */
.info-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #bfdbfe;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.info-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.b-inference { background: #dbeafe; color: #1d4ed8; }
.b-training  { background: #dcfce7; color: #15803d; }
.b-tpu       { background: #fce7f3; color: #be185d; }
.b-gpu       { background: #ede9fe; color: #6d28d9; }
.b-moe       { background: #fef9c3; color: #854d0e; margin-left: 4px; }

/* Metric pill */
td.td-metric { text-align: center; }
.metric-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 12.5px;
  min-width: 64px;
  text-align: center;
}
.mp-high { background: var(--green-bg); color: var(--green); }
.mp-mid  { background: var(--amber-bg); color: var(--amber); }
.mp-low  { background: var(--red-bg);   color: var(--red);   }
.mp-na   { color: var(--muted); font-weight: 400; font-size: 12px; }

/* Empty / error state */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .es-icon { font-size: 36px; margin-bottom: 14px; }
.empty-state h2 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p  { font-size: 13px; line-height: 1.6; max-width: 480px; margin: 0 auto 16px; }
.empty-state pre {
  display: inline-block;
  text-align: left;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--text);
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 700px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: pop-in .18s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

.modal-hd {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-hd h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  font-family: ui-monospace, monospace;
  line-height: 1.4;
  word-break: break-all;
}
.modal-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal-bd { padding: 18px 22px 22px; }

.m-section { margin-bottom: 18px; }
.m-section:last-child { margin-bottom: 0; }
.m-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.m-desc {
  font-size: 13px;
  line-height: 1.7;
  color: #374151;
  background: var(--bg);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.kv-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 4px 14px;
}
.kv-k { font-size: 12px; color: var(--muted); }
.kv-v { font-size: 12px; font-weight: 500; word-break: break-word; }
.kv-v a { color: var(--accent); }

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 6px;
}
.metric-row .mr-label { font-size: 13px; font-weight: 600; }
.metric-row .mr-desc  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 16px 24px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
