/* PkgFire dashboard.
   One stylesheet, no build step. Alpine drives interactivity; this file only
   describes appearance. */

:root {
  --bg:        #faf9f7;
  --panel:     #ffffff;
  --panel-alt: #f6f4f1;
  --ink:       #17150f;
  --ink-2:     #4a443c;
  --muted:     #7c7469;
  --line:      #e6e1da;
  --line-2:    #d6cfc5;

  --brand:      #c2410c;
  --brand-ink:  #9a3412;
  --brand-soft: #fff3ec;

  --allow:      #15803d;
  --allow-soft: #eefaf1;
  --warn:       #b45309;
  --warn-soft:  #fff8eb;
  --block:      #b91c1c;
  --block-soft: #fef2f2;

  --r:    10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(23,21,15,.04), 0 1px 3px rgba(23,21,15,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #141210;
    --panel:     #1d1a16;
    --panel-alt: #262119;
    --ink:       #f5f0e8;
    --ink-2:     #cdc5b8;
    --muted:     #9a9184;
    --line:      #332d25;
    --line-2:    #443c31;

    --brand:      #fb923c;
    --brand-ink:  #fdba74;
    --brand-soft: #2b1a0f;

    --allow:      #4ade80;
    --allow-soft: #122117;
    --warn:       #fbbf24;
    --warn-soft:  #281f10;
    --block:      #f87171;
    --block-soft: #2a1414;

    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .875em;
}
code {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  padding: .5px 5px;
  border-radius: 4px;
  word-break: break-word;
}

a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.01em; font-weight: 640; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 640; }
p  { margin: 0 0 10px; }

.lede  { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.hint  { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- chrome */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 0 22px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 660; font-size: 15px; color: var(--ink);
  padding: 13px 14px 13px 0; margin-right: 6px;
}
.brand:hover { text-decoration: none; }
.brand svg { display: block; }

.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: var(--muted); font-size: 13.5px; font-weight: 520;
  padding: 14px 11px; border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar nav a.on { color: var(--ink); border-bottom-color: var(--brand); }

.signout { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.who { color: var(--muted); font-size: 12.5px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 22px 56px; }
.foot {
  max-width: 1180px; margin: 0 auto;
  padding: 0 22px 34px; color: var(--muted); font-size: 12.5px;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 6px;
}
.crumb { margin: 0 0 10px; font-size: 13px; }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
section + section { margin-top: 30px; }

.empty {
  background: var(--panel);
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  padding: 34px 22px; text-align: center; color: var(--muted);
}
.empty p { margin: 0 0 6px; }

.cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 26px; align-items: start; }

/* ----------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 15px 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-2);
}
.stat-allow::before { background: var(--allow); }
.stat-warn::before  { background: var(--warn); }
.stat-block::before { background: var(--block); }

.stat-n { display: block; font-size: 27px; font-weight: 620; letter-spacing: -.03em; line-height: 1.15; }
.stat-l { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.stat-allow .stat-n { color: var(--allow); }
.stat-warn  .stat-n { color: var(--warn); }
.stat-block .stat-n { color: var(--block); }

/* ---------------------------------------------------------------- tables */

.tablewrap {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow);
}
/* A table is the one thing allowed to scroll sideways on a narrow screen. */
.tablewrap.scrolls { overflow-x: auto; }

.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.grid th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 620; background: var(--panel-alt);
  position: sticky; top: 0;
}
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: var(--panel-alt); }
.grid tr.dim { opacity: .5; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  padding: 10px 0; border-bottom: 1px solid var(--line);
  display: flex; gap: 9px; align-items: baseline; flex-wrap: wrap;
}
.list li:last-child { border-bottom: none; }

.meta { display: grid; grid-template-columns: max-content 1fr; gap: 7px 22px; margin: 0 0 22px; }
.meta dt { color: var(--muted); font-size: 12.5px; }
.meta dd { margin: 0; font-size: 13.5px; }

/* --------------------------------------------------------------- badges */

.badge, .sev, .status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2.5px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 680; letter-spacing: .05em;
  text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-allow { background: var(--allow-soft); color: var(--allow); border-color: color-mix(in srgb, var(--allow) 25%, transparent); }
.badge-warn  { background: var(--warn-soft);  color: var(--warn);  border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.badge-block { background: var(--block-soft); color: var(--block); border-color: color-mix(in srgb, var(--block) 25%, transparent); }
.badge-muted { background: var(--panel-alt);  color: var(--muted); border-color: var(--line); }

.sev-critical { background: var(--block-soft); color: var(--block); border-color: color-mix(in srgb, var(--block) 35%, transparent); }
.sev-high     { background: var(--block-soft); color: var(--block); }
.sev-medium   { background: var(--warn-soft);  color: var(--warn); }
.sev-low      { background: var(--panel-alt);  color: var(--muted); border-color: var(--line); }
.sev-info     { background: var(--panel-alt);  color: var(--muted); border-color: var(--line); }

.status-ok      { background: var(--allow-soft); color: var(--allow); }
.status-bad     { background: var(--block-soft); color: var(--block); }
.status-pending { background: var(--warn-soft);  color: var(--warn); }

.verdict-hero {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 15px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 680; letter-spacing: .04em; text-transform: uppercase;
  border: 1px solid transparent;
}
.verdict-hero.badge-allow { border-color: color-mix(in srgb, var(--allow) 30%, transparent); }
.verdict-hero.badge-warn  { border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.verdict-hero.badge-block { border-color: color-mix(in srgb, var(--block) 30%, transparent); }

/* -------------------------------------------------------------- findings */

.toolbar {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  padding: 12px 0 16px;
}
.toolbar .spacer { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button {
  border: 0; background: var(--panel); color: var(--muted);
  padding: 6px 11px; font-size: 12.5px; font-weight: 560; cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); background: var(--panel-alt); }
.seg button.on { background: var(--brand); color: #fff; }

.search {
  flex: 0 1 280px; min-width: 180px;
  padding: 7px 11px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink);
}

.fgroup { margin-bottom: 22px; }
.fgroup-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 0 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px;
}
.fgroup-head .pkg { font-weight: 620; font-size: 14px; }

.finding {
  display: grid; grid-template-columns: 82px 1fr;
  gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line);
  align-items: start;
}
.finding:last-child { border-bottom: none; }
.finding-title { font-size: 13.5px; line-height: 1.45; }
.finding-id { color: var(--muted); font-size: 12px; }
.finding-sub { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.fix { color: var(--allow); font-size: 12px; font-weight: 560; }
.reach { color: var(--block); font-size: 12px; font-weight: 560; }

.coverage {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  padding: 12px 15px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-bottom: 18px;
}

.reasons { list-style: none; padding: 0; margin: 0; }
.reasons li { border-left: 3px solid var(--line-2); padding: 9px 0 9px 14px; margin-bottom: 11px; }
.reasons li.v-block { border-left-color: var(--block); }
.reasons li.v-warn  { border-left-color: var(--warn); }
.reasons p { margin: 5px 0 0; color: var(--ink-2); font-size: 13px; }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 12.5px; font-weight: 620; margin-bottom: 5px; }
label.check {
  font-weight: 440; display: grid; grid-template-columns: auto 1fr;
  gap: 9px; align-items: start; margin-bottom: 13px; font-size: 13.5px;
}
label.check input { margin: 3px 0 0; }
label.check .hint { grid-column: 2; margin-top: 2px; }

input[type=text], input[type=email], input[type=number], input[type=search], select {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink); font-size: 13.5px;
  font-family: inherit;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

fieldset { border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin: 0 0 16px; }
legend { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 7px; font-weight: 640; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  font-size: 13.5px; font-weight: 590; cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger  { color: var(--block); border-color: color-mix(in srgb, var(--block) 40%, var(--line)); background: transparent; }
.btn-quiet   { background: transparent; border-color: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--ink); background: var(--panel-alt); border-color: var(--line); }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

.row-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row-form > div { flex: 1 1 200px; }

/* --------------------------------------------------------------- alerts */

.alert { border-radius: var(--r); padding: 14px 16px; margin-bottom: 20px; border: 1px solid; }
.alert-good { background: var(--allow-soft); border-color: color-mix(in srgb, var(--allow) 30%, transparent); }
.alert-bad  { background: var(--block-soft); border-color: color-mix(in srgb, var(--block) 30%, transparent); }
.alert-warn { background: var(--warn-soft);  border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert p:last-child { margin-bottom: 0; }

/* Grid, not flex. With flex the command box collapsed to a sliver and the
   Copy button took the row: a nowrap <pre> as a flex item has an intrinsic
   min-width that fights flex-shrink, and the interaction is subtle enough
   that it was wrong twice. `1fr auto` says what is meant with no ambiguity -
   the command takes the space, the button takes its label. */
.keybox {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px; align-items: stretch; margin: 11px 0;
}
.key {
  min-width: 0;
  background: var(--ink); color: var(--bg);
  padding: 11px 13px; border-radius: var(--r-sm);
  overflow-x: auto; margin: 0; user-select: all; white-space: nowrap;
}
.keybox .btn { white-space: nowrap; }

/* The install command is the page's primary call to action, so it wraps
   rather than hiding half of itself behind a scrollbar. An API key stays
   nowrap: it is one token, and wrapping it invites a broken copy-paste. */
.key-wrap { white-space: pre-wrap; overflow-x: visible; word-break: break-all; }

@media (max-width: 520px) {
  .keybox { grid-template-columns: 1fr; }
  .keybox .btn { justify-self: start; }
}

/* ----------------------------------------------------------------- auth */

.auth { max-width: 400px; margin: 8vh auto; }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head h1 { font-size: 25px; display: inline-flex; align-items: center; gap: 9px; }
.auth .btn { width: 100%; justify-content: center; margin-top: 14px; }
.auth .card { padding: 22px; }

/* --------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .cols  { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding: 20px 16px 44px; }
  .topbar { padding: 0 16px; }
  .topbar nav { order: 3; width: 100%; border-top: 1px solid var(--line); }
  .topbar nav a { padding: 11px 9px; }
  .signout { margin-left: auto; }
  .finding { grid-template-columns: 1fr; gap: 5px; }
  .stats { grid-template-columns: 1fr 1fr; }
}
