:root {
  --bg: #0b0f14;
  --bg-soft: #111821;
  --panel: #141d27;
  --panel-2: #182330;
  --line: #253242;
  --line-soft: #1d2936;
  --text: #e6edf3;
  --muted: #8fa3b8;
  --accent: #4cc2ff;
  --accent-2: #2f9ed8;
  --ok: #42d392;
  --warn: #f3b64b;
  --bad: #ff6b6b;
  --info: #63a8ff;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 12px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #132638 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.8rem; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1.2rem; }
p { margin: .2rem 0 .8rem; }
code, pre, .mono { font-family: var(--mono); }
code { background: #0a1118; border: 1px solid var(--line); padding: .1rem .3rem; border-radius: 5px; font-size: .85em; }
pre { background: #070c11; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; overflow: auto; font-size: .78rem; }

.topbar {
  display: flex; align-items: center; gap: 1.4rem;
  padding: .75rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 20, .9);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); font-weight: 700; letter-spacing: .02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #2b6fe0);
  color: #041018; font-size: .72rem; font-weight: 800;
}
.nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: .4rem .6rem; border-radius: 7px; }
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--panel-2); }
.account { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.link-button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }
.link-button:hover { color: var(--bad); }
.container { width: min(1500px, calc(100% - 2rem)); margin: 1.4rem auto 3rem; }
.container.container-wide { width: min(1900px, calc(100% - 1.5rem)); }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem 1.4rem; color: var(--muted); border-top: 1px solid var(--line-soft); font-size: .78rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.page-head h1 { margin-bottom: .2rem; }
.crumbs { color: var(--muted); font-size: .8rem; margin-bottom: .3rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.right { text-align: right; }
.text-bad { color: var(--bad); }
.subtle { color: var(--muted); font-size: .8rem; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .48rem .8rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer; font: inherit;
  white-space: nowrap;
}
.button:hover { border-color: #3a4b60; text-decoration: none; background: #1d2a39; }
.button.primary { background: linear-gradient(180deg, var(--accent), var(--accent-2)); border-color: transparent; color: #041018; font-weight: 700; }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { color: var(--bad); border-color: #5a2a2f; background: #25161a; }
.button.small { padding: .28rem .55rem; font-size: .78rem; }
.actions form { display: inline; }

.panel { background: linear-gradient(180deg, var(--panel), #111923); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .7rem; }
.panel-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: 1.25fr 1fr; gap: 1rem; align-items: start; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat-grid.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat { background: linear-gradient(180deg, var(--panel-2), #111923); border: 1px solid var(--line); border-radius: 10px; padding: .8rem .9rem; }
.stat-label { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; font-size: 1.6rem; line-height: 1.2; margin-top: .2rem; }

.table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line-soft); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th { text-align: left; color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; background: #0e151d; padding: .55rem .65rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: .55rem .65rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(76, 194, 255, .035); }

.asset-table-wrap { -webkit-overflow-scrolling: touch; }
.asset-table { min-width: 1580px; table-layout: auto; }
.asset-table thead th { position: sticky; top: 0; z-index: 2; }
.asset-table td { white-space: normal; overflow-wrap: anywhere; word-break: normal; }
.asset-table .asset-host-cell { min-width: 230px; max-width: 330px; }
.asset-table .asset-host { font-family: var(--mono); font-size: .82rem; }
.asset-table .asset-badges { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .25rem; }
.asset-table .asset-wrap-cell { min-width: 150px; max-width: 260px; }
.asset-table .asset-source-cell { min-width: 130px; }
.asset-table .asset-date-cell { min-width: 142px; white-space: nowrap; }
.asset-table .asset-nowrap { white-space: nowrap; }
.asset-table td:nth-child(2) { min-width: 78px; white-space: nowrap; }
.asset-table td:nth-child(3) { min-width: 170px; }
.asset-table td:nth-child(4) { min-width: 72px; }
.asset-table td:last-child { min-width: 66px; white-space: nowrap; }
.enrichment-state { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; }
.badge.new-badge { color: #200609; background: #ff5d66; border-color: #ff8b90; box-shadow: 0 0 0 1px rgba(255, 93, 102, .22), 0 0 12px rgba(255, 93, 102, .18); }

.manual-add-panel { border-color: #2d4660; }
.manual-add-form { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; }
.manual-add-form .manual-host-field { flex: 1 1 360px; max-width: 720px; }
.enrichment-banner { margin: .8rem 0 0; }

.target-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.target-card { display: flex; flex-direction: column; gap: .85rem; margin-bottom: 0; }
.target-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.target-card-head h2 { margin-bottom: .1rem; }
.target-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.target-metrics div { background: #0f1720; border: 1px solid var(--line-soft); border-radius: 8px; padding: .5rem .6rem; }
.target-metrics strong { display: block; font-size: 1.2rem; line-height: 1.2; }
.target-metrics span { display: block; color: var(--muted); font-size: .7rem; margin-top: .15rem; }
.target-card-meta { display: flex; gap: .6rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.target-card .actions { margin-top: auto; }

.badge { display: inline-block; padding: .12rem .42rem; border-radius: 999px; font-size: .68rem; font-weight: 700; letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap; }
.badge.ok { color: var(--ok); background: rgba(66, 211, 146, .1); border-color: rgba(66, 211, 146, .25); }
.badge.warn { color: var(--warn); background: rgba(243, 182, 75, .1); border-color: rgba(243, 182, 75, .25); }
.badge.bad { color: var(--bad); background: rgba(255, 107, 107, .1); border-color: rgba(255, 107, 107, .25); }
.badge.info { color: var(--info); background: rgba(99, 168, 255, .1); border-color: rgba(99, 168, 255, .25); }
.badge.muted { color: var(--muted); background: rgba(143, 163, 184, .08); border-color: rgba(143, 163, 184, .2); }

.flash { border-radius: 9px; padding: .65rem .85rem; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--panel); }
.flash.ok { border-color: rgba(66, 211, 146, .35); background: rgba(66, 211, 146, .07); }
.flash.error { border-color: rgba(255, 107, 107, .4); background: rgba(255, 107, 107, .08); }
.flash.warn { border-color: rgba(243, 182, 75, .35); background: rgba(243, 182, 75, .07); }
.flash code { display: block; margin-top: .5rem; padding: .5rem; white-space: normal; overflow-wrap: anywhere; }

.empty { color: var(--muted); padding: 1.2rem .4rem; }
.change-list { list-style: none; margin: 0; padding: 0; }
.change-list li { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px solid var(--line-soft); }
.change-list li:last-child { border-bottom: 0; }
.change-list .muted.small { margin-left: auto; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.span-2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: .28rem; color: var(--muted); font-size: .8rem; }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-size: .86rem; }
input, select, textarea {
  width: 100%; background: #0b1219; border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: .5rem .6rem; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(76, 194, 255, .12); }
textarea { resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 9px; padding: .8rem; margin: 0; }
legend { color: var(--muted); padding: 0 .35rem; font-size: .78rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; }
.input-suffix { display: flex; align-items: center; gap: .45rem; }
.input-suffix input { max-width: 130px; }
.input-suffix span { color: var(--muted); font-size: .8rem; }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .65rem; align-items: end; }
.filter-actions { display: flex; gap: .5rem; align-items: end; }
.filter-check { padding-bottom: .35rem; }
.danger-zone { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }

progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 999px; overflow: hidden; background: #0b1219; }
progress::-webkit-progress-bar { background: #0b1219; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), var(--ok)); }
progress::-moz-progress-bar { background: var(--accent); }
.progress-meta { display: flex; justify-content: space-between; gap: 1rem; margin-top: .4rem; color: var(--muted); font-size: .78rem; }

.log { max-height: 520px; overflow: auto; background: #070c11; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; font-family: var(--mono); font-size: .76rem; }
.log-line { display: grid; grid-template-columns: 62px 92px 1fr; gap: .5rem; padding: .12rem 0; border-bottom: 1px solid rgba(37, 50, 66, .35); }
.log-line:last-child { border-bottom: 0; }
.log-time { color: #5f7387; }
.log-stage { color: var(--accent); overflow: hidden; text-overflow: ellipsis; }
.log-line.warning span:last-child { color: var(--warn); }
.log-line.error span:last-child { color: var(--bad); }
.log-line.debug { opacity: .7; }

.details { display: grid; grid-template-columns: 150px 1fr; gap: .35rem .8rem; margin: 0; }
.details dt { color: var(--muted); font-size: .8rem; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.compact-details { margin-top: 1rem; }
.raw-details summary { cursor: pointer; color: var(--muted); }
.raw-details pre { margin: .8rem 0 0; max-height: 480px; }

.pagination { display: flex; align-items: center; gap: .8rem; margin-top: .8rem; }
.error-panel { max-width: 640px; margin: 3rem auto; }
.error-panel h1 { font-size: 3rem; color: var(--warn); }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card { width: min(440px, 100%); background: linear-gradient(180deg, var(--panel), #101821); border: 1px solid var(--line); border-radius: 16px; padding: 1.6rem; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.login-brand { margin-bottom: .3rem; }
.login-subtitle { margin-bottom: 1.2rem; }
.login-card .button { width: 100%; margin-top: .3rem; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .account { margin-left: 0; }
  .container, .container.container-wide { width: calc(100% - 1rem); }
  .target-card-grid { grid-template-columns: 1fr; }
  .target-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-add-form { align-items: stretch; }
  .manual-add-form .manual-host-field { max-width: none; }
  .manual-add-form .button { width: 100%; }
  .stat-grid, .stat-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .filter-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .details { grid-template-columns: 1fr; }
  .details dt { margin-top: .3rem; }
  .log-line { grid-template-columns: 54px 1fr; }
  .log-stage { display: none; }
}
