/* style.css — hand-rolled dark theme. No framework, no Tailwind.
   Everything tunable lives at :root level so future themes are one-edit. */

:root {
  --bg:       #0c0c10;
  --surface:  #16161d;
  --surface2: #1e1e27;
  --line:     #2a2a36;
  --text:     #fafafa;
  --muted:    #b4b4be;
  --dim:      #7a7a89;
  --accent:   #ef4444;
  --grade-A:  #3ddc7e;
  --grade-B:  #9bd76b;
  --grade-C:  #f0c14b;
  --grade-D:  #f08c4b;
  --grade-F:  #ef4444;
  --radius:   12px;
  --gap:      18px;
  --mono:     ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans:     system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(255,255,255,0.25); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

code { font-family: var(--mono); background: var(--surface); padding: 0 4px; border-radius: 4px; color: var(--muted); font-size: 0.88em; }

.container { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.hidden { display: none !important; }

/* ----- header ----- */
.page-head {
  padding: 36px 0 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(239,68,68,0.06), rgba(239,68,68,0) 80%);
}
.brand { display: inline-flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 18px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(239,68,68,0.18); }
.brand-name { letter-spacing: 0.02em; }
.lead { color: var(--muted); max-width: 760px; margin: 12px 0 0; }
.banner { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius); background: rgba(240,193,75,0.1); border: 1px solid rgba(240,193,75,0.3); color: #f6dca0; font-size: 14px; }

/* ----- stats ----- */
.stats-strip { padding: 22px 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.stats-row { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: var(--gap); }
.stat { background: var(--surface2); padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); }
.stat-num { font-size: 26px; font-weight: 700; font-family: var(--mono); }
.stat-label { color: var(--dim); font-size: 12px; margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; }
.stat.grade-A .stat-num { color: var(--grade-A); }
.stat.grade-B .stat-num { color: var(--grade-B); }
.stat.grade-C .stat-num { color: var(--grade-C); }
.stat.grade-D .stat-num { color: var(--grade-D); }
.stat.grade-F .stat-num { color: var(--grade-F); }
.refresh-stat { display: flex; flex-direction: column; gap: 6px; }
.refresh-btn { margin-top: 4px; background: var(--accent); color: #fff; border: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-family: var(--mono); font-size: 12px; }
.refresh-btn:hover { filter: brightness(1.1); }
.refresh-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ----- filters ----- */
.filters { padding: 20px 0; }
.filter-row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: flex-end; }
.filter-row label { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-row label.grow { flex: 1; min-width: 220px; }
.filter-label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.filter-row select,
.filter-row input[type=search] {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-family: var(--mono);
  font-size: 14px;
}
.filter-row select:focus,
.filter-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ----- main grid ----- */
.main-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; padding: 0 24px 60px; }
@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ----- cards ----- */
.leaderboard-card, .feed-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface2); }
.card-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; margin: 0; color: var(--dim); }
.card-meta { font-family: var(--mono); font-size: 12px; color: var(--dim); }

/* ----- table ----- */
.table-wrap { overflow-x: auto; }
table.leaderboard { width: 100%; border-collapse: collapse; min-width: 880px; }
.leaderboard th, .leaderboard td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.leaderboard th { font-weight: 600; color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface2); position: sticky; top: 0; }
.leaderboard tbody tr { transition: background 0.12s; }
.leaderboard tbody tr:hover { background: var(--surface2); cursor: pointer; }
.col-rank { width: 40px; color: var(--dim); font-family: var(--mono); }
.col-grade { width: 70px; }
.col-num { width: 82px; text-align: right; font-family: var(--mono); }
.col-sec { width: 60px; text-align: right; font-family: var(--mono); }
.col-action { width: 80px; text-align: right; }
.col-pin { font-family: var(--mono); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.col-category { color: var(--muted); font-size: 13px; }
.col-name { font-weight: 600; }
.col-name .archived-tag,
.col-name .missing-tag { display: inline-block; padding: 1px 6px; background: rgba(239,68,68,0.18); border: 1px solid rgba(239,68,68,0.4); color: var(--grade-F); font-size: 10.5px; border-radius: 4px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.col-num.warn { color: var(--grade-D); }
.col-num.bad { color: var(--grade-F); }
.col-sec.has { color: var(--grade-F); font-weight: 700; }

.grade-badge {
  display: inline-block;
  width: 30px;
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
  padding: 3px 0;
  border-radius: 6px;
  color: #0a0a0e;
}
.grade-badge.A { background: var(--grade-A); }
.grade-badge.B { background: var(--grade-B); }
.grade-badge.C { background: var(--grade-C); }
.grade-badge.D { background: var(--grade-D); }
.grade-badge.F { background: var(--grade-F); color: #fff; }

.details-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.details-btn:hover { color: var(--text); border-color: var(--muted); }

.empty { padding: 22px 16px; text-align: center; color: var(--dim); }

/* ----- feed ----- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 720px; overflow-y: auto; }
.feed li { padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed li:last-child { border-bottom: none; }
.feed .ev-type { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; font-family: var(--mono); margin-right: 8px; }
.ev-type.pin_updated  { background: rgba(61,220,126,0.16); color: var(--grade-A); }
.ev-type.grade_change { background: rgba(240,193,75,0.18); color: var(--grade-C); }
.ev-type.archived,
.ev-type.path_missing,
.ev-type.security_commit_appeared { background: rgba(239,68,68,0.18); color: var(--grade-F); }
.ev-type.first_seen { background: rgba(120,120,180,0.18); color: #c7c7e6; }
.feed .ev-meta { color: var(--dim); font-size: 11.5px; margin-top: 2px; }
.feed .ev-plugin { color: var(--text); font-weight: 600; }

/* ----- modal ----- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.72); backdrop-filter: blur(4px); }
.modal-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; max-width: 880px; width: calc(100vw - 40px); max-height: calc(100vh - 48px); overflow-y: auto; padding: 28px 28px 24px; box-shadow: 0 24px 60px rgba(0,0,0,0.45); }
.modal-close { position: absolute; top: 14px; right: 14px; background: transparent; border: none; color: var(--dim); font-size: 18px; cursor: pointer; }
.modal-close:hover { color: var(--text); }

.modal h3 { margin: 0 0 4px; font-size: 22px; }
.modal .subhead { color: var(--muted); font-size: 14px; }
.modal .meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 18px; margin: 18px 0; font-size: 13px; }
.modal .meta-grid div span { color: var(--dim); }
.modal section { margin-top: 20px; }
.modal h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--dim); }
.modal .commit-line { padding: 6px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.modal .commit-line.sec { color: var(--grade-F); }
.modal .commit-line .sha { color: var(--text); margin-right: 8px; }
.modal .copy-row { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.modal .copy-row code { flex: 1; font-size: 12px; padding: 6px 8px; }
.modal .copy-row button { background: var(--accent); border: none; color: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; }
.modal .grade-big { font-size: 80px; font-weight: 800; font-family: var(--mono); }

/* ----- footer ----- */
.page-foot { border-top: 1px solid var(--line); padding: 22px 0 32px; color: var(--muted); font-size: 13px; }
