:root {
  --bg: #0b0e12;
  --panel: #11161c;
  --panel-2: #151b22;
  --panel-3: #1a212a;
  --line: #242c36;
  --line-strong: #303a46;
  --text: #e8edf3;
  --muted: #8995a5;
  --subtle: #657181;
  --blue: #5b8def;
  --blue-hover: #6b99f3;
  --green: #4fb982;
  --amber: #d6a24a;
  --red: #d96868;
  --radius: 10px;
  --shadow: 0 14px 40px rgba(0,0,0,.22);
  --sidebar: 196px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
::selection { background: rgba(91,141,239,.32); }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  background: #0e1217;
  border-right: 1px solid var(--line);
  padding: 20px 14px 16px;
  z-index: 30;
}
.sidebar-head { height: 38px; display: flex; align-items: center; padding: 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .08em; color: #dce4ed; }
.nav { display: grid; gap: 4px; margin-top: 12px; }
.nav-link { height: 38px; display: flex; align-items: center; padding: 0 10px; border-radius: 7px; color: var(--muted); font-weight: 550; }
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.025); }
.nav-link.active { color: #f3f6fa; background: #171e26; }
.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--subtle); cursor: pointer; font-size: 12px; }
.text-button:hover { color: var(--text); }
.page-wrap { grid-column: 2; min-width: 0; }
.page { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 38px 0 56px; }
.mobile-bar { display: none; }

.page-head, .job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; line-height: 1.25; letter-spacing: -.025em; font-weight: 650; }
h2 { margin: 0; font-size: 13px; letter-spacing: .01em; font-weight: 650; color: #cbd4de; }
h3 { font-size: 17px; line-height: 1.3; margin-bottom: 18px; }
.break { overflow-wrap: anywhere; word-break: break-word; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.scan-panel { padding: 16px; }
.scan-form { display: flex; align-items: end; gap: 10px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 550; }
.compact-label > span { color: #cbd4de; font-size: 13px; font-weight: 650; }
.grow { flex: 1; min-width: 0; }
input, select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  background: #0d1217;
  color: var(--text);
  border-radius: 7px;
  outline: none;
  padding: 0 12px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder { color: #566170; }
input:focus, select:focus { border-color: #4f78be; box-shadow: 0 0 0 3px rgba(91,141,239,.09); background: #0f141a; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #6f7d8d 50%), linear-gradient(135deg, #6f7d8d 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .08s ease;
}
.button:active { transform: translateY(1px); }
.button.primary { background: var(--blue); color: #07111f; border-color: var(--blue); }
.button.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }
.button.secondary { background: #171d25; border-color: var(--line-strong); color: #d4dce6; }
.button.secondary:hover { background: #1b232d; }
.button.danger { background: #7b3538; border-color: #934246; color: #fff; }
.button.danger:hover { background: #8a3b3f; }
.button.danger.ghost { background: transparent; color: #df8a8a; border-color: #553033; }
.button.danger.ghost:hover { background: rgba(217,104,104,.07); }
.button.full { width: 100%; }
.button.small { min-height: 32px; padding: 0 11px; font-size: 12px; }
.scan-button { height: 40px; min-width: 92px; }

.section-block { margin-top: 26px; }
.section-head { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.section-head.inside { padding: 14px 15px 8px; margin: 0; }
.section-link { color: var(--muted); font-size: 12px; }
.section-link:hover { color: var(--text); }
.count { color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 22px 2px; }

.activity-card {
  min-height: 76px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
}
.activity-card:hover { border-color: #33404f; background: #12181f; }
.activity-main { min-width: 0; }
.target-text, .row-title { color: #e2e8ef; font-weight: 600; min-width: 0; }
.meta-row, .row-sub { display: flex; gap: 10px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.list-panel { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.list-row { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row:hover { background: #141a21; }

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status.running { background: rgba(91,141,239,.10); color: #8eb2f6; border-color: rgba(91,141,239,.22); }
.status.queued { background: rgba(214,162,74,.08); color: #d7ad67; border-color: rgba(214,162,74,.18); }
.status.completed { background: rgba(79,185,130,.09); color: #78cda1; border-color: rgba(79,185,130,.19); }
.status.failed { background: rgba(217,104,104,.09); color: #e58a8a; border-color: rgba(217,104,104,.18); }
.status.cancelled { background: rgba(137,149,165,.08); color: #9aa5b3; border-color: rgba(137,149,165,.16); }
.status.mini { min-height: 20px; font-size: 10px; padding: 0 7px; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--panel); }
.table-wrap.embedded { border: 0; border-radius: 0; background: transparent; }
.table { width: 100%; border-collapse: collapse; min-width: 660px; }
.table th { height: 38px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--subtle); text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.table td { padding: 11px 14px; border-top: 1px solid var(--line); color: #b8c2ce; vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table .strong { color: #dfe6ee; font-weight: 560; }
.click-row { cursor: pointer; }
.click-row:hover td { background: #141a21; }
.table.compact { min-width: 760px; }
.table.compact td { font-size: 12px; }

.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) 150px auto; gap: 9px; margin-bottom: 14px; }
.search-input { min-width: 0; }

.job-title-wrap { min-width: 0; }
.back-link { display: inline-flex; margin-bottom: 8px; color: var(--subtle); font-size: 12px; }
.back-link:hover { color: var(--muted); }
.job-title { max-width: 780px; font-size: 22px; }
.job-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 7px; }
.job-meta > * + *::before { content: "·"; margin-right: 10px; color: #4e5966; }
.job-actions { display: flex; align-items: center; gap: 8px; padding-top: 25px; }
.state-card { min-height: 52px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 0 15px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.state-label { color: #d8e0e9; font-weight: 600; }

.tabs { height: 42px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); margin: 4px 0 22px; }
.tab { height: 42px; display: inline-flex; align-items: center; color: var(--muted); font-size: 13px; position: relative; }
.tab:hover { color: var(--text); }
.tab.active { color: #e6ebf1; }
.tab.active::after { content: ""; height: 2px; background: var(--blue); position: absolute; left: 0; right: 0; bottom: -1px; border-radius: 2px 2px 0 0; }
.export-menu { margin-left: auto; position: relative; }
.export-menu > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu[open] > summary { color: var(--text); }
.export-popover { position: absolute; right: 0; top: 30px; z-index: 10; width: 120px; padding: 5px; background: #151b22; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); }
.export-popover a { display: block; padding: 8px 9px; border-radius: 5px; color: #c6cfda; font-size: 12px; }
.export-popover a:hover { background: #1d2530; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
.metric { min-height: 76px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 13px 15px; display: grid; align-content: center; gap: 3px; }
.metric strong { font-size: 21px; font-weight: 650; letter-spacing: -.02em; }
.metric span { color: var(--muted); font-size: 11px; }

.finding-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.finding-row { border-top: 1px solid var(--line); }
.finding-row:first-child { border-top: 0; }
.finding-row > summary { min-height: 54px; list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 14px; }
.finding-row > summary::-webkit-details-marker { display: none; }
.finding-row[open] > summary { background: #141a21; }
.finding-main { min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.finding-value { min-width: 0; color: #e1e7ee; font-weight: 570; }
.finding-kind, .muted-kind { color: var(--subtle); font-size: 11px; text-transform: capitalize; }
.confidence { color: #8da1b8; font-size: 11px; white-space: nowrap; }
.finding-detail, .result-detail { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px 18px; padding: 12px 14px 14px; border-top: 1px solid var(--line); background: #0f141a; }
.finding-detail > div, .result-detail > div { min-width: 0; display: grid; gap: 3px; }
.finding-detail span, .result-detail span { color: var(--subtle); font-size: 10px; text-transform: uppercase; letter-spacing: .045em; }
.finding-detail strong, .result-detail strong { color: #bfc8d3; font-size: 12px; font-weight: 520; overflow-wrap: anywhere; }

.result-section { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.result-section > summary { height: 48px; list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; color: #cfd7e0; font-weight: 600; font-size: 13px; }
.result-section > summary::-webkit-details-marker { display: none; }
.result-section > summary:hover { background: #141a21; }
.result-section[open] > summary { border-bottom: 1px solid var(--line); }
.result-table { background: #0f141a; }
.result-row { border-top: 1px solid var(--line); }
.result-row:first-child { border-top: 0; }
.result-row > summary { min-height: 44px; list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0,1fr) 150px; gap: 18px; align-items: center; padding: 8px 14px; color: #c4cdd8; }
.result-row > summary::-webkit-details-marker { display: none; }
.result-row > summary:hover { background: rgba(255,255,255,.018); }
.result-row .muted-kind { text-align: right; }
.collector-grid { background: #0f141a; }
.collector-row { min-height: 48px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); }
.collector-row:first-child { border-top: 0; }
.collector-row strong { font-size: 12px; font-weight: 550; }
.collector-error { display: block; max-width: 740px; color: #b87a7a; font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
.collector-side { display: flex; align-items: center; gap: 10px; color: var(--subtle); font-size: 11px; }
.warning-section > summary { color: #d5ba87; }
.warning-list { margin: 0; padding: 12px 30px 15px; color: #bba888; background: #12120f; font-size: 12px; }
.warning-list li + li { margin-top: 6px; }

.notice { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start; color: #b9c3ce; font-size: 12px; }
.notice.error { border-color: #4d2b2d; background: rgba(217,104,104,.05); color: #cf9292; }
.notice.neutral { background: var(--panel); }
.notice strong { color: #e3b0b0; white-space: nowrap; }
.report-frame-wrap { height: calc(100vh - 180px); min-height: 620px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #0d1116; }
.report-frame { width: 100%; height: 100%; border: 0; background: #0d1116; }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, .8fr); gap: 12px; align-items: start; }
.user-list { padding: 0 14px 10px; }
.user-row { min-height: 58px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.user-row:first-child { border-top: 0; }
.row-menu { position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; color: var(--muted); font-size: 12px; padding: 6px 0; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu-pop { position: absolute; right: 0; top: 31px; width: 130px; padding: 5px; z-index: 12; background: #151b22; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); }
.row-menu-pop button { width: 100%; border: 0; background: transparent; color: #c8d0da; text-align: left; padding: 8px 9px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.row-menu-pop button:hover { background: #1d2530; }
.row-menu-pop .danger-text { color: #d98585; }
.inline-form { display: flex; align-items: end; gap: 9px; padding: 4px 14px 14px; }

.dialog { width: min(430px, calc(100vw - 32px)); border: 1px solid var(--line-strong); border-radius: 11px; background: #131920; color: var(--text); padding: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.48); }
.dialog::backdrop { background: rgba(3,6,10,.70); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 13px; }
.dialog-form h3 { margin-bottom: 3px; }
.dialog-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog-form .dialog-actions { margin-top: 5px; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 14px; }
.flash { min-height: 38px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; color: #bec7d2; background: var(--panel); font-size: 12px; }
.flash.error { border-color: #4f3032; color: #db9898; background: rgba(217,104,104,.045); }
.flash.success { border-color: #284638; color: #8bc6a8; background: rgba(79,185,130,.045); }

.login-body { background: #090c10; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #10151b; box-shadow: 0 20px 70px rgba(0,0,0,.26); display: grid; gap: 14px; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.inline-error { padding: 8px 10px; border: 1px solid #4f3032; border-radius: 7px; background: rgba(217,104,104,.04); color: #d89393; font-size: 12px; text-align: center; }
.error-card { text-align: center; }
.error-code { font-size: 34px; font-weight: 650; letter-spacing: -.04em; }
.error-page { min-height: 55vh; display: grid; place-items: center; align-content: center; gap: 12px; text-align: center; color: var(--muted); }
.error-page p, .error-card p { margin-bottom: 4px; color: var(--muted); }

@media (max-width: 840px) {
  :root { --sidebar: 190px; }
  .shell { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: 18px 0 60px rgba(0,0,0,.25); }
  .sidebar.open { transform: translateX(0); }
  .page-wrap { min-width: 0; }
  .mobile-bar { height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: #0d1116; position: sticky; top: 0; z-index: 20; color: var(--muted); font-size: 12px; }
  .menu-button { border: 0; background: transparent; color: #d0d7df; padding: 5px 0; cursor: pointer; }
  .page { width: min(100% - 28px, 900px); padding: 24px 0 44px; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page { width: min(100% - 22px, 900px); padding-top: 20px; }
  h1 { font-size: 21px; }
  .scan-form { align-items: stretch; flex-direction: column; }
  .scan-button { width: 100%; }
  .filter-bar { grid-template-columns: 1fr 120px; }
  .filter-bar .button { grid-column: 1 / -1; }
  .job-head { flex-direction: column; gap: 12px; }
  .job-actions { padding-top: 0; width: 100%; }
  .job-actions .button { margin-left: auto; }
  .metrics { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .metric { min-height: 66px; padding: 10px; }
  .metric strong { font-size: 18px; }
  .finding-main { display: grid; gap: 2px; }
  .finding-detail, .result-detail { grid-template-columns: 1fr; }
  .result-row > summary { grid-template-columns: minmax(0,1fr) 90px; }
  .collector-row { align-items: flex-start; }
  .collector-side { flex-direction: column; align-items: flex-end; gap: 5px; }
  .tabs { gap: 14px; }
  .report-frame-wrap { min-height: 520px; height: calc(100vh - 150px); }
}
