/* App shell palette: the original dark navy, with the blue accents swapped for
   green (links, buttons, active nav, brand, glow). */
:root {
  --bg: #0f1420; --panel: #161c2b; --panel-2: #1d2436; --line: #2a3246;
  --ink: #e8ecf4; --muted: #93a0b8; --brand: #2fd16f; --brand-2: #1f9d54;
  --glow: rgba(47,209,111,.38);
  --critical: #ff2d78; --high: #ff5c6c; --medium: #ffb020; --low: #46c08a;
  --info: #8fa3b5; --chip: #223049;
}
/* Login page keeps the purple identity (scoped to the page with the particle
   canvas), so only the authenticated app turns green. */
body:has(#particles-js) {
  --bg: #0c0a14; --panel: #15101f; --panel-2: #1e1730; --line: #2f2544;
  --ink: #ece8f6; --muted: #9c90b8; --brand: #c07bff; --brand-2: #7c3aed;
  --glow: rgba(192,123,255,.45); --chip: #271d3d;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 20px; letter-spacing: .5px; padding: 4px 10px 18px; }
.brand-text span { color: #ff2a4d; text-shadow: 0 0 12px rgba(255,42,77,.55); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 36px; height: 36px; flex: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--muted); padding: 10px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--ink); }
.sidebar nav a.active { background: var(--brand-2); color: #fff; box-shadow: 0 0 16px var(--glow); }
.sidebar nav.nav-bottom { margin-top: auto; }
.nav-badge { display: inline-block; min-width: 20px; padding: 1px 7px; margin-left: 4px;
  background: var(--medium); color: #1a1a1a; border-radius: 999px; font-size: 12px;
  font-weight: 700; text-align: center; }
.sidebar-foot { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.who { color: var(--ink); font-weight: 600; padding: 0 10px; }
.who span { display: block; color: var(--muted); font-weight: 400; font-size: 12px; text-transform: capitalize; }
.logout { display: inline-block; margin: 10px 10px 0; color: var(--muted); }
.logout.linkbtn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }

.app-version { color: var(--muted); font-size: 11px; opacity: .8; padding: 12px 10px 0; }
.login-card .app-version { position: absolute; right: 16px; bottom: 12px; padding: 0; color: rgba(255,255,255,.55); }

.content { flex: 1; min-width: 0; }
.topbar { padding: 22px 28px 10px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; }
.page { padding: 22px 28px 48px; }

/* ---- KPI tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.tile .n { font-size: 30px; font-weight: 700; }
.tile .k { color: var(--muted); font-size: 13px; }
.tile.high .n { color: var(--high); }
.tile.warn .n { color: var(--medium); }
.qrbox { background: #fff; padding: 12px; border-radius: 10px; display: inline-block; line-height: 0; }
.qrbox svg { width: 184px; height: 184px; display: block; }
/* Multi-select filter dropdowns (Findings): a button that reveals checkboxes. */
.filter-dd { position: relative; }
.filter-dd > summary { list-style: none; cursor: pointer; user-select: none;
  padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink); display: inline-flex; align-items: center;
  gap: 7px; white-space: nowrap; font-size: 13px; }
.filter-dd > summary::-webkit-details-marker { display: none; }
.filter-dd > summary::after { content: "\25BE"; color: var(--muted); font-size: 10px; }
.filter-dd[open] > summary { border-color: var(--brand); color: var(--brand); }
.filter-dd[open] > summary::after { color: var(--brand); }
.dd-count { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px;
  line-height: 17px; min-width: 17px; text-align: center; padding: 0 5px; }
.dd-panel { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 190px;
  box-shadow: 0 12px 34px rgba(0,0,0,.45); }
.dd-panel.dd-scroll { max-height: 280px; overflow-y: auto; }
.dd-panel .check { white-space: nowrap; }

/* ---- cards & tables ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 22px; overflow: hidden; }
.card h2 { margin: 0; padding: 14px 18px; font-size: 15px; border-bottom: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---- badges ---- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.sev-critical { background: rgba(255,45,120,.18); color: var(--critical); box-shadow: 0 0 10px rgba(255,45,120,.35); }
.sev-high { background: rgba(255,92,108,.16); color: var(--high); }
.sev-medium { background: rgba(255,176,32,.16); color: var(--medium); }
.sev-low { background: rgba(70,192,138,.16); color: var(--low); }
.sev-informational, .sev-info { background: rgba(143,163,181,.16); color: var(--info); }
.chip { background: var(--chip); color: var(--ink); padding: 2px 9px; border-radius: 6px; font-size: 12px; }
.status { color: var(--muted); text-transform: capitalize; }
.flag { color: var(--high); font-weight: 600; }

/* ---- filters / buttons ---- */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-label { color: var(--muted); font-size: 12px; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check { flex-direction: row !important; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.check input { accent-color: var(--brand); margin: 0; }
select, input[type=text], input[type=password] { background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
.btn { background: var(--brand-2); color: #fff; border: none; border-radius: 8px; padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 0 14px var(--glow); transition: all .15s; }
.btn:hover { background: var(--brand); box-shadow: 0 0 20px var(--glow); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: transparent; border: 1px solid var(--high); color: var(--high); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.muted { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---- login ---- */
/* The wrapper lets pointer events fall through to the particle canvas so the
   background stays interactive (hover = grab, click = push); only the card
   itself captures the mouse. */
.login-wrap { min-height: 100vh; display: flex; justify-content: flex-end; position: relative;
  z-index: 1; pointer-events: none; }
/* Colour glows behind the panel so the glass has something to refract. */
.login-wrap::before { content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(420px 380px at 88% 24%, rgba(255,42,77,.38), transparent 70%),
              radial-gradient(520px 460px at 96% 78%, rgba(124,58,237,.42), transparent 70%),
              radial-gradient(300px 300px at 70% 55%, rgba(0,229,255,.16), transparent 70%); }
/* Sign-in panel docked to the right edge: frosted "iOS glass" side bar. */
.login-card { position: relative; width: 420px; max-width: 100%; min-height: 100vh;
  box-sizing: border-box; display: flex; flex-direction: column; justify-content: center;
  padding: 40px; pointer-events: auto;
  background: linear-gradient(160deg, rgba(255,255,255,.16), rgba(255,255,255,.05) 55%, rgba(255,255,255,.09));
  -webkit-backdrop-filter: blur(32px) saturate(180%); backdrop-filter: blur(32px) saturate(180%);
  border-left: 1px solid rgba(255,255,255,.28);
  box-shadow: inset 1px 0 0 rgba(255,255,255,.22), inset 0 1px 0 rgba(255,255,255,.3),
              -24px 0 60px rgba(0,0,0,.45); }
.login-card form input[type=text], .login-card form input[type=password] { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.18); }
.login-card form input::placeholder { color: rgba(255,255,255,.55); }
.login-card form input[type=text]:focus, .login-card form input[type=password]:focus { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.55); outline: 0; }
.login-card .btn { box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 20px rgba(124,58,237,.4); }
.login-card .brand { padding: 0 0 6px; flex-direction: column; gap: 4px; font-size: 26px; }
.login-card .brand-logo { width: 84px; height: 84px; }
.login-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card input { width: 100%; }
.login-err { background: rgba(255,92,108,.14); color: var(--high); padding: 10px 12px;
  border-radius: 8px; font-size: 13px; }
.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- particles login background ---- */
#particles-js { position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(1100px 560px at 72% -10%, rgba(124,58,237,.16), transparent 60%),
    radial-gradient(900px 500px at 15% 110%, rgba(192,123,255,.10), transparent 60%),
    var(--bg); }
#particles-js canvas { display: block; }

/* ---- forms (create org / add assets / start scan) ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; padding: 16px 18px; align-items: end; }
.card > form { padding: 16px 18px; }
.card > form .form-grid { padding: 0; }
form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12px; }
form input[type=text], form input[type=password], form select, form textarea {
  width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px; }
form textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.form-actions { margin-top: 14px; grid-column: 1 / -1; }
.tier-note { grid-column: 1 / -1; margin: 2px 0 0; color: var(--muted); font-size: 12.5px;
  border-left: 2px solid var(--brand-2); padding: 6px 10px 6px 12px; background: var(--panel-2); border-radius: 0 6px 6px 0; }
.notice { background: rgba(47,209,111,.10); border: 1px solid rgba(47,209,111,.3);
  color: var(--ink); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* ---- scan detail: metadata + live console ---- */
.scan-meta { display: flex; gap: 28px; flex-wrap: wrap; margin-bottom: 20px; }
.scan-meta > div { display: flex; flex-direction: column; gap: 4px; }
.scan-meta .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.console { background: #0b0f18; border-top: 1px solid var(--line); padding: 14px 18px;
  max-height: 460px; overflow-y: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.55; }
.log-line { white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.log-line.k-phase  { color: var(--brand); font-weight: 600; margin-top: 4px; }
.log-line.k-check  { color: var(--ink); }
.log-line.k-signal { color: var(--medium); font-weight: 600; }
.log-line.k-result { color: var(--low); font-weight: 600; margin-top: 4px; }
.log-line.k-error  { color: var(--high); font-weight: 600; }
.log-line.k-info   { color: var(--muted); }
.spinner { display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: middle;
  border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; }
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- asset arrow (jump to asset across the platform) ---- */
.asset-arrow { display: inline-block; margin-left: 6px; color: var(--brand);
  font-weight: 700; text-decoration: none; opacity: .75; }
.asset-arrow:hover { opacity: 1; text-decoration: none; }

/* ---- tags ---- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0;
  background: var(--chip); color: var(--ink); border: 1px solid var(--line); }
.tag-green  { background: rgba(70,192,138,.15);  color: var(--low);      border-color: rgba(70,192,138,.4); }
.tag-red    { background: rgba(255,92,108,.15);  color: var(--high);     border-color: rgba(255,92,108,.4); }
.tag-blue   { background: rgba(124,140,255,.15); color: var(--info);     border-color: rgba(124,140,255,.4); }
.tag-amber  { background: rgba(255,176,32,.15);  color: var(--medium);   border-color: rgba(255,176,32,.4); }
.tag-purple { background: rgba(192,123,255,.15); color: #c07bff;         border-color: rgba(192,123,255,.4); }
.tag-slate  { background: var(--chip); color: var(--muted); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-x { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px;
  line-height: 1; padding: 0 0 0 2px; opacity: .7; }
.tag-x:hover { opacity: 1; }

/* ---- table search + sortable headers ---- */
.table-search { margin: 0 0 12px; }
.table-search input { width: 260px; max-width: 100%; background: var(--panel-2);
  color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable-th:hover { color: var(--ink); }
/* Persistent neutral sort icon so columns read as sortable; coloured arrow when active. */
th.sortable-th::after { content: " \21C5"; opacity: .4; font-size: 11px; }
th.sortable-th.sorted-asc::after { content: " \2191"; opacity: 1; color: var(--brand); }
th.sortable-th.sorted-desc::after { content: " \2193"; opacity: 1; color: var(--brand); }

/* ---- finding / asset detail prose ---- */
.prose { padding: 14px 18px; }
.prose p { margin: 0 0 10px; }
.prose p:last-child { margin-bottom: 0; }
.codeblock { margin: 0; padding: 14px 18px; background: #0b0f18; color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  line-height: 1.6; overflow-x: auto; white-space: pre; border-top: 1px solid var(--line); }
.refs { margin: 0; padding: 14px 18px 16px 34px; }
.refs li { margin-bottom: 8px; }

/* ---- finding triage ---- */
.triage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.triage-box { display: flex; flex-direction: column; gap: 6px; }
.triage-box textarea { width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13px; resize: vertical; }
.triage-box select { background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }

/* ---- collapsible rule groups (Scan rules) ---- */
.rule-group { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.rule-group > summary { padding: 12px 16px; cursor: pointer; font-weight: 600;
  background: var(--panel-2); list-style: none; }
.rule-group > summary::-webkit-details-marker { display: none; }
.rule-group > summary::before { content: "▸ "; color: var(--brand); }
.rule-group[open] > summary::before { content: "▾ "; }
.rule-group[open] > summary { border-bottom: 1px solid var(--line); }
.rule-group table td { padding: 8px 16px; border-bottom: 1px solid var(--line); }
.rule-group tr:last-child td { border-bottom: none; }

/* Users page: row actions sit on one line, forms inline */
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions form { display: flex; gap: 6px; align-items: center; margin: 0; }
td form { margin: 0; }
