:root {
  --bg: #0b1220;
  --bg-elevated: #141c30;
  --bg-card: #17203a;
  --border: #26314f;
  --text: #e7ecf7;
  --text-muted: #8b96b3;
  --accent: #f2b807;
  --accent-2: #22d3ee;
  --normal: #22c55e;
  --warning: #f2b807;
  --critical: #ef4444;
  --unreachable: #6b7280;
  --radius: 14px;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top left, #101a30 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent-2); }

/* ---------- Auth page ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }

.auth-brand-mark {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #10182c;
  font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}

.auth-brand-title { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
.auth-brand-subtitle { font-size: 13px; color: var(--text-muted); }

.auth-tagline {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 18px 0 24px;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.auth-form input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.auth-form input:focus { outline: none; border-color: var(--accent-2); }

.auth-form button {
  margin-top: 20px;
  background: linear-gradient(135deg, var(--accent), #d9a406);
  color: #10182c;
  border: none;
  padding: 11px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.auth-form button:hover { filter: brightness(1.05); }

.auth-footer { margin-top: 22px; font-size: 11.5px; color: var(--text-muted); text-align: center; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 28px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #10182c;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

.brand-title { font-weight: 700; font-size: 15px; }
.brand-subtitle { font-size: 11.5px; color: var(--text-muted); margin-top: -2px; }

.topbar-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.topbar-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
}
.topbar-nav a:hover { color: var(--text); background: var(--bg-card); }
.topbar-nav a.active { color: var(--text); background: var(--bg-card); border: 1px solid var(--border); }

.topbar-status {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--border);
}
.topbar-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.status-normal .dot { background: var(--normal); box-shadow: 0 0 8px var(--normal); }
.status-warning .dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-critical .dot { background: var(--critical); box-shadow: 0 0 8px var(--critical); }
.status-unreachable .dot { background: var(--unreachable); }

.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.link-btn { background: none; border: none; color: var(--accent-2); cursor: pointer; font-size: 13px; padding: 0; }

/* ---------- Content ---------- */
.content { max-width: 1180px; margin: 0 auto; padding: 28px; }

.section-header { display: flex; align-items: baseline; gap: 12px; margin: 34px 0 16px; }
.section-header h2 { font-size: 16px; margin: 0; }
.muted { color: var(--text-muted); font-size: 13px; }
.muted.small { font-size: 11.5px; }
.count-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  margin-left: 4px;
}

/* Agent cards */
.agents-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.agent-role {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #10182c;
  background: var(--accent-2);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.agent-name { font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.agent-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin: 0; }

/* Target cards */
.targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
}
.target-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.target-card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.target-name { font-weight: 700; font-size: 15px; }
.target-kind { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.badge-normal { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.4); }
.badge-warning { background: rgba(242,184,7,0.15); color: #fbbf24; border: 1px solid rgba(242,184,7,0.4); }
.badge-critical { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.badge-unreachable { background: rgba(107,114,128,0.15); color: #9ca3af; border: 1px solid rgba(107,114,128,0.4); }

.metric-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.metric-row { display: grid; grid-template-columns: 36px 1fr 44px; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.bar { background: var(--bg-elevated); border-radius: 999px; height: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.metric-value { text-align: right; color: var(--text); font-weight: 600; }

.target-detail { font-size: 12.5px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 12px; }
.target-detail strong { color: var(--text); }
.risk-flag { color: #f87171; font-weight: 700; margin-top: 4px; }
.ok-flag { color: #4ade80; font-weight: 600; margin-top: 4px; }
.target-updated { font-size: 11px; color: var(--text-muted); margin-top: 12px; }

/* Incidents table */
.incidents-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.incidents-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--bg-card); }
.incidents-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.incidents-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.incidents-table tr:last-child td { border-bottom: none; }

.sev { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.sev-low { background: rgba(107,114,128,0.15); color: #9ca3af; }
.sev-medium { background: rgba(242,184,7,0.15); color: #fbbf24; }
.sev-high { background: rgba(239,68,68,0.12); color: #f87171; }
.sev-critical { background: rgba(239,68,68,0.25); color: #fca5a5; }

.heal { font-size: 11.5px; font-weight: 700; }
.heal-yes { color: #4ade80; }
.heal-no { color: var(--text-muted); }

.page-footer { text-align: center; color: var(--text-muted); font-size: 11.5px; margin: 48px 0 12px; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar-status { order: 3; margin-left: 0; }
}

/* ---------- Messages ---------- */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.message {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
}
.message-success { background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.35); color: #4ade80; }
.message-error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.35); color: #f87171; }

/* ---------- Buttons & links ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #d9a406);
  color: #10182c;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary, .btn-secondary-link {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary-link { display: inline-flex; align-items: center; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; text-decoration: none; }
.btn-danger { background: rgba(239,68,68,0.15); color: #fca5a5; border: 1px solid rgba(239,68,68,0.4); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.inline-actions { display: flex; gap: 10px; margin-top: 16px; }

.actions-cell a { color: var(--accent-2); text-decoration: none; margin-right: 14px; font-size: 13px; }
.actions-cell a.danger-link { color: #f87171; }
.actions-cell a:hover { text-decoration: underline; }

/* ---------- Forms (user management) ---------- */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 460px;
  margin-bottom: 20px;
}
.form-card-title { font-size: 14px; margin: 0 0 16px; }
.form-card label { display: block; font-size: 12px; color: var(--text-muted); margin-top: 14px; margin-bottom: 6px; }
.form-card label:first-child { margin-top: 0; }
.form-card input[type="text"],
.form-card input[type="password"],
.form-card input[type="email"] {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.form-card input[type="text"]:focus,
.form-card input[type="password"]:focus { outline: none; border-color: var(--accent-2); }
.form-card input[type="checkbox"] { margin-right: 8px; }
.form-card button[type="submit"] { margin-top: 20px; }
.field-help { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.field-error { font-size: 12px; color: #f87171; margin-top: 4px; }

.access-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-top: 1px solid var(--border); font-size: 13.5px;
}
.access-row:first-of-type { border-top: none; padding-top: 0; }
