*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf9f7;
  --bg-card: #fff;
  --fg: #2c2420;
  --fg-muted: #7a6e64;
  --border: #e4ddd6;
  --red: #7b2d34;
  --red-dark: #5c1f26;
  --red-light: #f5eaea;
  --green: #1a7f37;
  --green-bg: #dafbe1;
  --red-badge: #cf222e;
  --red-badge-bg: #ffebe9;
  --hover: #f0ece8;
  --focus: #7b2d3440;
  --radius: 5px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

body { font: 14px/1.5 var(--font); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.header { background: #c00; color: #fff; padding: 10px 0; }
.header-inner { max-width: 1400px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.prompt-btn { background: transparent; color: #fff; border-color: rgba(255,255,255,0.3); font-size: 11px; }
.prompt-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Container */
.container { max-width: 1400px; margin: 0 auto; padding: 16px; overflow: hidden; }

/* Loading */
.loading-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; font-size: 13px; color: var(--fg-muted); }
.loading-row { display: flex; align-items: center; gap: 16px; }
.loading-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.loading-bar-fill { height: 100%; background: var(--red); border-radius: 2px; transition: width 0.3s ease-out; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-done { background: var(--green); }
.dot-loading { background: var(--border); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Preset bar */
.filter-bar-wrap { margin-bottom: 12px; }
.preset-bar { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.preset-btn {
  padding: 5px 12px; font: inherit; font-size: 12px; font-weight: 500; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; background: var(--bg-card); color: var(--fg-muted);
  transition: all 0.1s;
}
.preset-btn:hover { background: var(--hover); color: var(--fg); }
.preset-btn.active { background: var(--red-dark); color: #fff; border-color: var(--red-dark); }
.preset-btn-wrap { display: inline-flex; position: relative; }
.preset-delete {
  position: absolute; top: -4px; right: -4px; width: 14px; height: 14px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card);
  font-size: 10px; line-height: 1; cursor: pointer; display: none;
  align-items: center; justify-content: center; color: var(--fg-muted);
}
.preset-btn-wrap:hover .preset-delete { display: inline-flex; }
.preset-delete:hover { background: var(--red-badge-bg); color: var(--red-badge); border-color: var(--red-badge); }
.save-btn { border-style: dashed; color: var(--green); }
.save-btn:hover { background: var(--green-bg); }
.reset-btn { color: var(--fg-muted); font-size: 11px; }

/* View info */
.view-info { margin-bottom: 8px; font-size: 13px; line-height: 1.4; }
.view-info-header { display: flex; align-items: baseline; gap: 8px; }
.view-label { color: var(--fg); font-size: 14px; }
.view-desc-toggle {
  font: inherit; font-size: 11px; color: var(--red); background: none;
  border: none; cursor: pointer; padding: 0;
}
.view-desc-toggle:hover { text-decoration: underline; }
.view-details {
  margin-top: 6px; padding: 10px 12px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.view-desc { color: var(--fg-muted); margin: 0 0 8px; }
.view-json {
  font: 11px/1.4 var(--mono); color: var(--fg-muted); margin: 0;
  background: var(--bg); padding: 8px; border-radius: var(--radius);
  overflow-x: auto; max-height: 200px;
}

/* Filter bar */
.filter-bar { display: flex; align-items: center; gap: 8px; }
.filter-input {
  width: 240px; height: 32px; padding: 0 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card);
  outline: none; transition: border-color 0.15s;
}
.filter-input:focus { border-color: var(--red); box-shadow: 0 0 0 2px var(--focus); }
.toggle-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.toggle-btn {
  padding: 5px 12px; font: inherit; font-size: 13px; border: none; cursor: pointer;
  background: var(--bg-card); color: var(--fg-muted); transition: all 0.1s;
}
.toggle-btn:not(:first-child) { border-left: 1px solid var(--border); }
.toggle-btn:hover { background: var(--hover); color: var(--fg); }
.toggle-btn.active { background: var(--red-light); color: var(--red-dark); font-weight: 500; }

/* Table */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
thead { position: sticky; top: 0; z-index: 2; background: var(--bg); }
thead th {
  padding: 6px 12px; text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--fg-muted);
  border-bottom: 1px solid var(--border); user-select: none; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.05s; }
tbody tr:last-child { border-bottom: none; }
td { padding: 5px 8px; font-size: 13px; }

/* Org header (for org grouping) */
.org-header td {
  background: var(--red-light); padding: 8px 12px; font-size: 14px; font-weight: 700;
  color: var(--red-dark); border-bottom: 2px solid var(--border); letter-spacing: -0.01em;
}

/* Group header */
.group-header td {
  background: var(--bg); padding: 6px 12px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.group-header a { color: var(--fg); }
.group-header .org { color: var(--fg-muted); font-size: 12px; }
.group-header .name { font-weight: 600; }
.group-meta { margin-left: 10px; font-size: 11px; color: var(--fg-muted); }
.group-link { margin-left: 8px; font-size: 11px; padding: 1px 6px; vertical-align: middle; }

/* Branch rows */
.branch-row:hover { background: var(--hover); }
.repo-cell { word-break: break-word; }
.repo-cell a { color: var(--fg); }
.repo-cell .org { color: var(--fg-muted); font-size: 12px; }
.repo-cell .name { font-weight: 500; }
.branch-name-cell { padding-left: 24px; font-family: var(--mono); font-size: 12px; word-break: break-word; }
.version-cell { font-family: var(--mono); font-size: 12px; color: var(--fg-muted); }
.date-cell { color: var(--fg-muted); }
.links-cell .link-btns { flex-wrap: wrap; }

/* Show more */
.show-more-row td { padding: 4px 24px; }
.show-more-btn {
  font: inherit; font-size: 12px; color: var(--red); background: none;
  border: none; cursor: pointer; padding: 0;
}
.show-more-btn:hover { text-decoration: underline; }
.no-recent { font-size: 12px; color: var(--fg-muted); }

/* Footer */
.table-footer { padding: 6px 12px; font-size: 12px; color: var(--fg-muted); border-top: 1px solid var(--border); background: var(--bg); }

/* Badge */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.badge-pass { background: var(--green-bg); color: var(--green); }
.badge-fail { background: var(--red-badge-bg); color: var(--red-badge); }

/* Link buttons */
.link-btns { display: flex; gap: 4px; align-items: center; }
.link-btn {
  display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg-muted);
  background: var(--bg-card); text-decoration: none; transition: all 0.1s; cursor: pointer;
  font-family: var(--font); line-height: 1.5;
}
.link-btn:hover { background: var(--hover); color: var(--fg); text-decoration: none; }
.link-btn.rebuilt { opacity: 0.5; cursor: default; }

/* Empty / loading states */
.empty { padding: 48px 12px; text-align: center; color: var(--fg-muted); font-size: 14px; }

@media (max-width: 768px) {
  .filter-input { width: 160px; }
  .links-cell { width: auto; }
}
