/* ============================================================
   Pentest Platform — design system
   Goals: clean internal-tool aesthetic, consistent across pages,
   prints decently, fast on slow links (no external fonts).
   ============================================================ */

:root {
  /* color */
  --navy:        #0b2a5b;
  --navy-dark:   #061a3b;
  --navy-soft:   #5475a8;
  --bg:          #f6f8fb;
  --surface:     #ffffff;
  --border:      #e0e6ee;
  --border-strong:#cfd8e3;
  --text:        #1a2334;
  --text-mute:   #6b7a8f;
  --link:        #0b5cd0;
  --link-hover:  #084298;

  /* state */
  --ok-bg:       #e6f7ed;
  --ok-fg:       #1a6e3a;
  --warn-bg:     #fff4d6;
  --warn-fg:     #6b4f00;
  --err-bg:      #fdecee;
  --err-fg:      #a8252c;
  --info-bg:     #e8f1fb;
  --info-fg:     #084298;

  /* severity */
  --sev-info-bg: #eceff1; --sev-info-fg: #37474f;
  --sev-low-bg:  #fff3cd; --sev-low-fg:  #7a5b00;
  --sev-med-bg:  #ffe0b2; --sev-med-fg:  #7a4a00;
  --sev-high-bg: #f8d7da; --sev-high-fg: #721c24;
  --sev-crit-bg: #721c24; --sev-crit-fg: #ffffff;

  /* spacing */
  --s1:  4px; --s2:  8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* radius / shadow */
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px;
  --sh-sm: 0 1px 2px rgba(20,40,80,0.05);
  --sh-md: 0 1px 3px rgba(20,40,80,0.08), 0 1px 2px rgba(20,40,80,0.04);
  --sh-lg: 0 8px 24px rgba(20,40,80,0.10);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font);
  font-size: 14px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3, h4 { color: var(--navy); margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-mute); }

p { margin: 0 0 var(--s4) 0; }

code, pre {
  font-family: var(--mono); font-size: 12.5px;
  background: #f1f4f8; color: #2a3546;
  padding: 1px 5px; border-radius: var(--r-sm);
}
pre { padding: var(--s3) var(--s4); border: 1px solid var(--border); overflow-x: auto; line-height: 1.45; }

/* ===== Layout ===== */
.app-header {
  background: var(--navy);
  color: white;
  border-bottom: 1px solid var(--navy-dark);
  position: sticky; top: 0; z-index: 50;
}
.app-header .inner {
  max-width: 1200px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; gap: var(--s4);
}
.app-header .brand {
  font-weight: 650; font-size: 16px; color: white; letter-spacing: 0.3px;
}
.app-header .brand:hover { color: white; text-decoration: none; }
.app-header nav {
  display: flex; gap: var(--s4); margin-left: var(--s6);
}
.app-header nav a {
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.app-header nav a:hover { color: white; text-decoration: none; border-bottom-color: rgba(255,255,255,0.4); }
.app-header nav a.active { color: white; border-bottom-color: white; }
.app-header .spacer { flex: 1; }
.app-header .userbox {
  display: flex; align-items: center; gap: var(--s3);
  font-size: 13px; color: rgba(255,255,255,0.85);
}
.app-header .userbox .who { font-weight: 500; color: white; }
.app-header .userbox .role {
  background: rgba(255,255,255,0.16);
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}
.app-header .userbox a {
  color: rgba(255,255,255,0.85); padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.25); border-radius: var(--r-sm);
}
.app-header .userbox a:hover { background: rgba(255,255,255,0.1); color: white; text-decoration: none; }

.app-main {
  max-width: 1200px; margin: 0 auto;
  padding: var(--s8) var(--s6);
}

.page-title {
  display: flex; align-items: baseline; gap: var(--s3);
  margin-bottom: var(--s6);
}
.page-title .crumb { color: var(--text-mute); font-size: 13px; }
.page-title .crumb a { color: var(--text-mute); }
.page-title .crumb a:hover { color: var(--link); }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  margin-bottom: var(--s6);
  overflow: hidden;
}
.card-header {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #fafbfd;
}
.card-header h2 { font-size: 15px; }
.card-header .actions { display: flex; gap: var(--s2); }
.card-body { padding: var(--s5); }
.card-body.flush { padding: 0; }

.muted { color: var(--text-mute); font-size: 12.5px; }

/* ===== Tables ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  background: #fafbfd;
  font-weight: 600; color: var(--text-mute);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px;
  border-top: 1px solid var(--border);
}
.table tbody tr:hover td { background: #f9fbfe; }
.table tbody tr:last-child td { border-bottom: none; }
.table.flush-edges th:first-child, .table.flush-edges td:first-child { padding-left: var(--s5); }
.table.flush-edges th:last-child,  .table.flush-edges td:last-child  { padding-right: var(--s5); }

/* row state tints (used in findings table) */
.table tr.row-accepted td { background: #f0fbf4; }
.table tr.row-rejected td { background: #fef5f5; color: var(--text-mute); text-decoration: line-through; }
.table tr.row-pending  td { background: #fffaeb; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer;
  font: inherit; font-weight: 500; font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  background: white; color: var(--text);
  border-radius: var(--r-sm);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  text-decoration: none;
}
.btn:hover { background: #f3f6fa; text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: white; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); color: white; }
.btn-success { background: white; color: var(--ok-fg); border-color: #b6dec5; }
.btn-success:hover { background: var(--ok-bg); }
.btn-danger { background: white; color: var(--err-fg); border-color: #f0c2c6; }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== Badges / pills ===== */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}
.badge.state-pending, .badge.state-scoped, .badge.state-queued { background: #eceff1; color: #37474f; }
.badge.state-authorized, .badge.state-succeeded { background: var(--ok-bg); color: var(--ok-fg); }
.badge.state-rejected, .badge.state-failed { background: var(--err-bg); color: var(--err-fg); }
.badge.state-running, .badge.state-review, .badge.state-reported { background: var(--info-bg); color: var(--info-fg); }
.badge.state-skipped { background: #f5f5f5; color: #888; }

.badge.sev-info { background: var(--sev-info-bg); color: var(--sev-info-fg); }
.badge.sev-low { background: var(--sev-low-bg); color: var(--sev-low-fg); }
.badge.sev-medium { background: var(--sev-med-bg); color: var(--sev-med-fg); }
.badge.sev-high { background: var(--sev-high-bg); color: var(--sev-high-fg); }
.badge.sev-critical { background: var(--sev-crit-bg); color: var(--sev-crit-fg); }

.badge.role-admin { background: #ede7f6; color: #4527a0; }
.badge.role-analyst { background: #e1f5fe; color: #01579b; }

/* ===== Forms ===== */
.form-row { margin-bottom: var(--s4); }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-mute); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.input, .select {
  display: block; width: 100%;
  padding: 8px 11px;
  font: inherit; font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: white;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus, .select:focus {
  outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(11,42,91,0.12);
}
.form-actions { display: flex; gap: var(--s2); margin-top: var(--s4); }

/* ===== Login ===== */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: var(--s4); background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--sh-md); border-radius: var(--r-lg); padding: var(--s8); }
.login-card .brand { font-size: 18px; font-weight: 700; color: var(--navy); margin-bottom: var(--s2); }
.login-card .lede { color: var(--text-mute); margin-bottom: var(--s6); }
.login-card .err { background: var(--err-bg); color: var(--err-fg); padding: 8px 12px; border-radius: var(--r-sm); margin-top: var(--s3); font-size: 13px; display: none; }

/* ===== Dashboard ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); box-shadow: var(--sh-sm); }
.kpi .label { font-size: 11px; text-transform: uppercase; color: var(--text-mute); letter-spacing: 0.5px; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--text); margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* ===== Engagement detail ===== */
.summary-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s3) var(--s4); margin-bottom: var(--s4); box-shadow: var(--sh-sm);
}
.summary-bar .item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-mute); }
.summary-bar .item b { color: var(--text); font-weight: 600; }

.review-bar {
  display: flex; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4);
  background: #fffaeb; border: 1px solid #f3e2a3; border-radius: var(--r-md);
  margin-bottom: var(--s4); font-size: 13px;
}
.review-bar.ready { background: var(--ok-bg); border-color: #b6dec5; color: var(--ok-fg); }
.review-bar .grow { flex: 1; }

/* screenshot grid */
.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s3); }
.shot {
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); padding: 6px;
  box-shadow: var(--sh-sm); transition: transform .15s ease, box-shadow .15s ease;
}
.shot:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.shot img { display: block; width: 100%; height: 180px; object-fit: cover; object-position: top; border-radius: 3px; background: #f5f5f5; }
.shot .cap { font-size: 11px; word-break: break-all; margin-top: 6px; color: var(--text-mute); }

/* empty states */
.empty {
  text-align: center; padding: var(--s10); color: var(--text-mute); font-size: 13px;
}

/* utility */
.row { display: flex; align-items: center; gap: var(--s2); }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mb-2 { margin-bottom: var(--s2); }
.mb-4 { margin-bottom: var(--s4); }
.mt-4 { margin-top: var(--s4); }

/* error toast */
#err-toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--err-bg); color: var(--err-fg);
  padding: 12px 16px; border-radius: var(--r-md); border: 1px solid #f0c2c6;
  font-size: 13px; max-width: 360px;
  box-shadow: var(--sh-lg);
  display: none;
}
