/* PolicyGuard dashboard — terminal-mono. See .claude/skills/policyguard-dashboard. */

:root {
  --bg:        #0A0A0B;
  --surface:   #141417;
  --surface-2: #1B1C20;
  --border:    #26272B;
  --text:      #F4F4F5;
  --text-dim:  #6B6E76;
  --accent:    #C2F24A;
  --accent-2:  #CFF65E;
  --hatch:     #8A8E97; /* hatch line brightened to read on the dark canvas */

  --sev-critical: #F4604D;
  --sev-high:     #E8853D;
  --sev-medium:   #D8B23D;
  --sev-low:      #5B8FB0;
  --pass:         #3FCF8E;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

/* Uniform 4px radius everywhere; round/sharp exceptions overridden below. */
* { box-sizing: border-box; border-radius: 4px; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body { font-variant-numeric: tabular-nums; }

.app { max-width: 1320px; margin: 0 auto; padding: 22px 24px 40px; }

.eyebrow {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim);
}

/* ---- top bar (borderless, flush) ---- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 4px 0 18px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Brand mark: shield follows text color (stroke=currentColor), prompt is baked
   lime in the SVG. */
.mark { color: var(--text); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.wordmark { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-text .eyebrow { font-size: 9.5px; }

.search {
  flex: 1 1 auto; display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  padding: 8px 12px; min-width: 0;
}
.search:focus-within { border-color: var(--text-dim); }
.search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--text); font-family: var(--mono); font-size: 13px; min-width: 0;
}
.search input::placeholder { color: var(--text-dim); }
.kbd {
  font-size: 11px; color: var(--text-dim); border: 1px solid var(--border);
  padding: 1px 6px; background: var(--surface-2);
}

.actions { display: flex; gap: 8px; flex: 0 0 auto; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-family: var(--mono); font-size: 12.5px; font-weight: 500;
  padding: 8px 12px; cursor: pointer; transition: border-color .18s ease, transform .12s ease;
}
.btn:hover { border-color: var(--text-dim); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #11140A; font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn[data-static] { cursor: default; }
.btn[data-static]:hover { transform: none; }

.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; color: var(--text-dim); }
.btn .ico { color: inherit; }
.ico-lg { width: 34px; height: 34px; }

/* ---- meta strip ---- */
.meta { display: flex; justify-content: space-between; align-items: center;
  padding: 0 0 16px; font-size: 12px; color: var(--text); flex-wrap: wrap; gap: 6px; }
.meta-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta .dot { color: var(--text-dim); }
.meta-dim { color: var(--text-dim); }
.passrate { color: var(--text-dim); }
.passrate #passrate-num { color: var(--pass); font-weight: 600; }

/* ---- stat cards ---- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
.card { background: var(--bg); border: 1px solid var(--border); padding: 16px 18px; }
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat-head { display: flex; align-items: center; gap: 7px; }
.stat-dot { width: 7px; height: 7px; border-radius: 50% !important; background: var(--text-dim); }
.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; }
.stat-num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.stat-desc { font-size: 11px; color: var(--text-dim); }

.sev-dot-critical { background: var(--sev-critical); } .sev-text-critical { color: var(--sev-critical); }
.sev-dot-high     { background: var(--sev-high); }     .sev-text-high     { color: var(--sev-high); }
.sev-dot-medium   { background: var(--sev-medium); }   .sev-text-medium   { color: var(--sev-medium); }
.sev-dot-low      { background: var(--sev-low); }      .sev-text-low      { color: var(--sev-low); }
.sev-dot-pass     { background: var(--pass); }         .sev-text-pass     { color: var(--pass); }

/* ---- distribution bar ---- */
.distbar { display: flex; height: 8px; gap: 2px; margin-bottom: 20px; overflow: hidden; }
.distseg { height: 100%; min-width: 2px; border-radius: 2px !important; transition: width .5s ease; }
.distseg-pass { background: var(--pass); }
/* FAIL segments = diagonal hatch in their severity color */
.distseg-fail { border: 1px solid currentColor; }
.sev-fill-critical { color: var(--sev-critical); }
.sev-fill-high     { color: var(--sev-high); }
.sev-fill-medium   { color: var(--sev-medium); }
.sev-fill-low      { color: var(--sev-low); }
.sev-fill-info     { color: var(--sev-low); }
.distseg-fail.sev-fill-critical { background: repeating-linear-gradient(45deg, var(--sev-critical) 0 1.5px, transparent 1.5px 5px); }
.distseg-fail.sev-fill-high     { background: repeating-linear-gradient(45deg, var(--sev-high) 0 1.5px, transparent 1.5px 5px); }
.distseg-fail.sev-fill-medium   { background: repeating-linear-gradient(45deg, var(--sev-medium) 0 1.5px, transparent 1.5px 5px); }
.distseg-fail.sev-fill-low      { background: repeating-linear-gradient(45deg, var(--sev-low) 0 1.5px, transparent 1.5px 5px); }

/* ---- main grid ---- */
.grid { display: grid; grid-template-columns: 1.62fr 1fr; gap: 14px; align-items: start; }

.card-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title h2 { margin: 2px 0 0; font-size: 16px; font-weight: 600; }

/* segmented filter — active = outlined box, inactive = plain muted text */
.filters { display: flex; gap: 2px; background: var(--bg); }
.seg { background: transparent; border: 1px solid transparent; color: var(--text-dim);
  font-family: var(--mono); font-size: 12px; padding: 5px 11px; cursor: pointer;
  transition: border-color .18s ease, color .18s ease; }
.seg:hover { color: var(--text); }
.seg.active { color: var(--text); border-color: var(--text); }

/* ---- findings table ---- */
.table-wrap { width: 100%; }
table.findings { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.findings thead th {
  text-align: left; font-weight: 500; font-size: 10.5px; letter-spacing: 0.06em;
  color: var(--text-dim); padding: 0 10px 8px; border-bottom: 1px solid var(--border);
}
table.findings th.col-status, table.findings td.col-status { text-align: right; }
.row { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s ease; }
.row td { padding: 11px 10px; vertical-align: top; border-left: 2px solid transparent; }
.row:hover { background: rgba(255,255,255,.018); }
.row.selected { background: rgba(194,242,74,.05); }
.row.selected td:first-child { border-left-color: var(--accent); }
.row:focus-visible { outline: 1px solid var(--text-dim); outline-offset: -1px; }

.res-id { display: block; color: var(--text); }
.res-type { display: block; color: var(--text-dim); font-size: 10.5px; margin-top: 2px; }
.pol-title { display: block; color: var(--text); }
.pol-id { display: block; color: var(--text-dim); font-size: 10.5px; margin-top: 2px; }
.loc { color: var(--text-dim); }

/* severity pill — FAIL = hatch fill in severity color + 1px outline */
.pill { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 8px; color: var(--text); }
.pill-fail { border: 1px solid currentColor; }
.pill.sev-fill-critical { color: var(--sev-critical); background: repeating-linear-gradient(45deg, rgba(244,96,77,.32) 0 2px, transparent 2px 6px); }
.pill.sev-fill-high     { color: var(--sev-high);     background: repeating-linear-gradient(45deg, rgba(232,133,61,.32) 0 2px, transparent 2px 6px); }
.pill.sev-fill-medium   { color: var(--sev-medium);   background: repeating-linear-gradient(45deg, rgba(216,178,61,.30) 0 2px, transparent 2px 6px); }
.pill.sev-fill-low      { color: var(--sev-low);      background: repeating-linear-gradient(45deg, rgba(91,143,176,.30) 0 2px, transparent 2px 6px); }
.pill.sev-fill-info     { color: var(--sev-low);      background: repeating-linear-gradient(45deg, rgba(91,143,176,.30) 0 2px, transparent 2px 6px); }

.status { font-size: 10.5px; font-weight: 600; letter-spacing: 0.05em; }
.status-fail { color: var(--sev-critical); }
.status-pass { color: var(--pass); }

.empty, .clean, .detail-empty { color: var(--text-dim); font-size: 13px; padding: 28px 6px; text-align: center; }
.clean { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---- detail panel ---- */
.detail { position: sticky; top: 16px; }
.detail-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.detail-policy { color: var(--text-dim); font-size: 12px; }
.detail-head .status { margin-left: auto; }
.detail-title { margin: 0 0 16px; font-size: 17px; font-weight: 600; line-height: 1.3; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.meta-grid .k { display: block; font-size: 10px; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 3px; }
.meta-grid .v { display: block; font-size: 12.5px; word-break: break-all; }

.section { margin-top: 16px; }
.section .eyebrow { display: block; margin-bottom: 8px; }
.prose { margin: 0; font-size: 12.5px; color: var(--text); line-height: 1.55; }
.remediation-prose { margin-top: 12px; color: var(--text-dim); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tag { font-size: 10.5px; color: var(--text-dim); border: 1px solid var(--border); padding: 3px 7px; background: var(--surface-2); }

/* code / evidence */
.code { background: var(--surface-2); border: 1px solid var(--border); padding: 10px 0; font-size: 12px; overflow-x: auto; }
.code-file { padding: 0 12px 8px; color: var(--text-dim); font-size: 10.5px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.code-line { display: flex; gap: 12px; padding: 1px 12px; white-space: pre; }
.code-line .ln { color: var(--text-dim); text-align: right; min-width: 28px; user-select: none; }
.code-line .lc { color: var(--text); }
.code-line.offending { border-left: 2px solid; margin-left: -2px; }
.code-line.offending[data-sev="critical"] { background: rgba(244,96,77,.10); border-color: var(--sev-critical); }
.code-line.offending[data-sev="high"]     { background: rgba(232,133,61,.10); border-color: var(--sev-high); }
.code-line.offending[data-sev="medium"]   { background: rgba(216,178,61,.10); border-color: var(--sev-medium); }
.code-line.offending[data-sev="low"]      { background: rgba(91,143,176,.10); border-color: var(--sev-low); }
.code-line.offending[data-sev="info"]     { background: rgba(91,143,176,.10); border-color: var(--sev-low); }

/* remediation diff */
.diff .diff-line { display: flex; gap: 10px; padding: 1px 12px; white-space: pre; }
.diff .dg { width: 10px; color: var(--text-dim); user-select: none; }
.diff .dc { color: var(--text); }
.diff-add { background: rgba(63,207,142,.08); }
.diff-add .dg, .diff-add .dc { color: var(--pass); }
.diff-del { background: repeating-linear-gradient(45deg, rgba(244,96,77,.12) 0 2px, transparent 2px 6px); }
.diff-del .dg, .diff-del .dc { color: var(--sev-critical); }

.detail-foot { display: flex; gap: 8px; margin-top: 18px; }

.foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px;
  padding-top: 14px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-dim); flex-wrap: wrap; }

/* ---- responsive ---- */
html, body { max-width: 100%; overflow-x: hidden; }

@media (max-width: 1024px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail { position: static; }
}

@media (max-width: 640px) {
  .app { padding: 16px 14px 32px; }
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-num { font-size: 26px; }
  .card { padding: 14px 14px; }
  .card-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filters { flex-wrap: wrap; }
  .meta { font-size: 11px; }

  /* Reflow the findings table from columns into stacked cards. The fixed-width
     5-column grid does not fit a phone; instead each finding becomes a block
     with labeled fields, so nothing scrolls sideways. */
  table.findings, table.findings tbody, table.findings tr, table.findings td { display: block; width: 100%; }
  table.findings thead { display: none; }
  .row { border: 1px solid var(--border); border-radius: 4px; margin-bottom: 10px; padding: 4px 12px 10px; }
  .row.selected { background: rgba(194,242,74,.05); }
  .row.selected td:first-child { border-left: 0; }
  .row td { padding: 6px 0; border-left: 0 !important; border-bottom: 1px solid var(--border); }
  .row td:last-child { border-bottom: 0; }
  /* Tag each cell with its column name. */
  .row td.col-pol::before,
  .row td.col-sev::before,
  .row td.col-loc::before,
  .row td.col-status::before {
    content: attr(data-label);
    display: block; font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: 3px;
  }
  .col-sev, .col-status { text-align: left !important; }

  /* Code/evidence/diff scroll inside their own box rather than the page. */
  .code, .table-wrap { max-width: 100%; }
}

@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
}

/* ---- motion ---- */
.stat, .row, .distseg { will-change: auto; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
