*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #222536;
  --border:    #2d3148;
  --text:      #e2e4f0;
  --text-muted:#8b90b0;
  --accent:    #5b6af5;
  --accent-hover: #4a58e0;
  --high:      #ef4444;
  --high-bg:   #3b1219;
  --medium:    #f59e0b;
  --medium-bg: #3b2a0a;
  --low:       #3b82f6;
  --low-bg:    #0d2145;
  --info:      #6b7280;
  --info-bg:   #1f2127;
  --good:      #22c55e;
  --good-bg:   #0c2d1a;
  --radius:    10px;
  --sidebar-w: 220px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .75rem;
}

.logo-img {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
}

.logo-subtitle {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #00B4C8;
  padding-left: 2px;
  margin-top: .25rem;
}

.nav-links { display: flex; flex-direction: column; gap: .1rem; flex: 1; }

.sidebar-footer {
  padding: .75rem 0 0;
  border-top: 1px solid var(--border);
  margin-top: auto;
  display: flex;
  flex-direction: column;
}

.settings-btn,
.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  border-radius: 0;
}

.logout-btn { color: var(--text-muted); }
.logout-btn:hover { color: var(--high) !important; background: var(--high-bg) !important; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: .875rem;
}
.nav-link:hover  { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--surface2); color: var(--accent); border-left: 3px solid var(--accent); }

/* ── Content ── */
.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.view { display: none; }
.view.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 600; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filters select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .4rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  cursor: pointer;
}

/* ── Stats ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}
.stat-card.risk-high   { border-left: 3px solid var(--high);   background: var(--high-bg); }
.stat-card.risk-medium { border-left: 3px solid var(--medium); background: var(--medium-bg); }
.stat-card.risk-low    { border-left: 3px solid var(--low);    background: var(--low-bg); }
.stat-card.good        { border-left: 3px solid var(--good);   background: var(--good-bg); }

.stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.chart-wrap { padding: 1.25rem; height: 260px; }
.chart-wrap canvas { max-height: 100%; }

/* ── Asset Grid ── */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.asset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.asset-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.asset-name { font-weight: 600; font-size: 1rem; }
.asset-target { font-size: .8rem; color: var(--text-muted); font-family: monospace; }
.asset-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .25rem; }

.asset-risk-row {
  display: flex;
  gap: .5rem;
}
.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.risk-pill.high   { background: var(--high-bg);   color: var(--high); }
.risk-pill.medium { background: var(--medium-bg); color: var(--medium); }
.risk-pill.low    { background: var(--low-bg);    color: var(--low); }
.risk-pill.informational { background: var(--info-bg); color: var(--info); }

.asset-actions { display: flex; gap: .5rem; margin-top: auto; }

.badge {
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-fqdn     { background: #1e3a5f; color: #60a5fa; }
.badge-ip       { background: #1e3040; color: #94a3b8; }
.badge-baseline { background: #1a2e1a; color: #4ade80; }
.badge-full     { background: #2d1e3e; color: #c084fc; }
.badge-enabled  { background: #0c2d1a; color: #22c55e; }
.badge-disabled { background: #2d1a1a; color: #ef4444; }

.last-scan { font-size: .75rem; color: var(--text-muted); }

/* ── Issues List ── */
.issue-row {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.issue-row:last-child { border-bottom: none; }
.issue-row:hover { background: var(--surface2); }

.issue-alert  { font-weight: 600; font-size: .875rem; }
.issue-url    { font-size: .75rem; color: var(--text-muted); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-asset  { font-size: .8rem; color: var(--text-muted); }
.issue-date   { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }

.risk-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.risk-badge.high   { background: var(--high-bg);   color: var(--high); }
.risk-badge.medium { background: var(--medium-bg); color: var(--medium); }
.risk-badge.low    { background: var(--low-bg);    color: var(--low); }
.risk-badge.informational { background: var(--info-bg); color: var(--info); }

.issues-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.issues-header {
  display: grid;
  grid-template-columns: 120px 1fr 1fr auto;
  gap: 1rem;
  padding: .6rem 1.25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

/* ── Scan Log ── */
.scan-row {
  display: grid;
  grid-template-columns: 140px 1fr 80px 80px 80px 80px 120px;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.scan-row:last-child { border-bottom: none; }

.scan-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.scan-header {
  display: grid;
  grid-template-columns: 140px 1fr 80px 80px 80px 80px 120px;
  gap: .75rem;
  padding: .6rem 1.25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.status-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
}
.status-badge.completed { background: var(--good-bg);   color: var(--good); }
.status-badge.failed    { background: var(--high-bg);   color: var(--high); }
.status-badge.running   { background: #1e2d4a;           color: #60a5fa; }
.status-badge.pending   { background: var(--surface2);   color: var(--text-muted); }

/* ── Improvement Table ── */
.improvement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.improvement-table th {
  text-align: left;
  padding: .6rem 1.25rem;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.improvement-table td {
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.improvement-table tr:last-child td { border-bottom: none; }

.delta { font-weight: 600; }
.delta.improved { color: var(--good); }
.delta.worsened { color: var(--high); }
.delta.same     { color: var(--text-muted); }

/* ── Asset Risk Table ── */
.asset-risk-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.asset-risk-row-item:last-child { border-bottom: none; }

/* ── Buttons ── */
.btn {
  padding: .45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger    { background: var(--high-bg); color: var(--high); border: 1px solid #5a1e22; }
.btn-danger:hover:not(:disabled)    { background: #4a1018; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-large { width: 680px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }

.btn-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.5rem; line-height: 1;
}
.btn-close:hover { color: var(--text); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .75rem 1.5rem 0;
}
.form-group label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.form-group input, .form-group select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .55rem .75rem;
  border-radius: 6px;
  font-size: .875rem;
  width: 100%;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* ── Issue Detail ── */
.issue-detail { padding: 1.25rem 1.5rem; }
.issue-detail-header { margin-bottom: 1rem; }
.issue-detail h3 { font-size: 1rem; margin-bottom: .5rem; }
.issue-detail-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.issue-section { margin-bottom: 1rem; }
.issue-section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .35rem;
  font-weight: 600;
}
.issue-section p { font-size: .875rem; line-height: 1.6; color: var(--text); }
.issue-html-content { font-size: .875rem; line-height: 1.6; color: var(--text); }
.issue-html-content p { margin-bottom: .5rem; }
.issue-html-content p:last-child { margin-bottom: 0; }
.issue-url-tag {
  font-family: monospace;
  font-size: .8rem;
  background: var(--surface2);
  padding: .3rem .6rem;
  border-radius: 4px;
  word-break: break-all;
}
.issue-actions { display: flex; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .75rem 1.25rem;
  font-size: .875rem;
  z-index: 200;
  animation: slidein .2s ease;
}
.toast.hidden { display: none; }
.toast.success { border-left: 3px solid var(--good); }
.toast.error   { border-left: 3px solid var(--high); }

@keyframes slidein {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state p { margin-top: .5rem; font-size: .875rem; }

.scanning-indicator {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: #60a5fa;
}
.dot-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #60a5fa;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}

/* ── Scan log panel ── */
.scan-log-panel {
  margin-top: .5rem;
  background: #0a0c12;
  border: 1px solid #1e2540;
  border-radius: 6px;
  overflow: hidden;
}
.scan-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .75rem;
  background: #111525;
  border-bottom: 1px solid #1e2540;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #60a5fa;
  cursor: pointer;
  user-select: none;
}
.scan-log-header .log-toggle { color: var(--text-muted); font-size: .8rem; }
.scan-log-body {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .72rem;
  line-height: 1.6;
  padding: .5rem .75rem;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .05rem;
}
.scan-log-body.collapsed { display: none; }
.log-line { white-space: pre-wrap; word-break: break-all; }
.log-line.info    { color: #cbd5e1; }
.log-line.warn    { color: #fbbf24; }
.log-line.fail    { color: #f87171; }
.log-line.error   { color: #f87171; }
.log-line.pass    { color: #4ade80; }
.log-line.docker  { color: #475569; }
.log-line.verbose { color: #334155; }
.log-ts { color: #334155; margin-right: .4rem; }

/* ── JIRA ── */
.btn-jira {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: #0052CC;
  color: #fff;
  border: none;
  padding: .35rem .75rem;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-jira:hover    { background: #0747A6; }
.btn-jira:disabled { opacity: .6; cursor: not-allowed; }

.jira-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #0052CC;
  color: #fff;
  padding: .18rem .55rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s;
  vertical-align: middle;
}
.jira-badge:hover         { background: #0747A6; }
.jira-badge.done          { background: #006644; }
.jira-badge.done:hover    { background: #005236; }
.jira-badge.inprogress    { background: #0065FF; }

.jira-status-pill {
  background: rgba(255,255,255,.2);
  border-radius: 3px;
  padding: .1rem .35rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.jira-ticket-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

/* ── Settings modal ── */
.settings-section-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 1rem 1.5rem .75rem;
  border-bottom: 1px solid var(--border);
}

.label-hint {
  font-size: .72rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: .4rem;
}
.label-hint a { color: #60a5fa; text-decoration: none; }
.label-hint a:hover { text-decoration: underline; }

/* ── Modal tabs ── */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  gap: .25rem;
}

.modal-tab {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  padding: .7rem .75rem .6rem;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.modal-tab:hover  { color: var(--text); }
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-pane        { display: none; }
.tab-pane.active { display: block; }

/* ── User list ── */
.user-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .7rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info      { flex: 1; min-width: 0; }
.user-email     { font-size: .875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta      { font-size: .72rem; color: var(--text-muted); margin-top: .1rem; }

.role-badge {
  padding: .15rem .55rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.role-badge.role-admin { background: #2d1e3e; color: #c084fc; }
.role-badge.role-user  { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

.user-self-tag {
  font-size: .72rem;
  color: var(--text-muted);
  padding: .15rem .55rem;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Add-user inline form ── */
.add-user-form {
  padding: 1rem 1.5rem;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.add-user-form.hidden { display: none; }
.add-user-form .form-group { padding: 0 0 .65rem; }
.add-user-form .form-row   { gap: 1rem; }
.add-user-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: .25rem;
}
