/* =============================
   Aegis UI — base stylesheet
   ============================= */

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

:root {
  --bg:         #0f1117;
  --surface:    #1a1d27;
  --surface2:   #222636;
  --border:     #2e3347;
  --text:       #d4d8e8;
  --text-muted: #6b7280;
  --primary:    #4f8ef7;
  --primary-dk: #3a6fd8;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --neutral:    #6b7280;
  --sidebar-w:  220px;
  --radius:     6px;
  --font:       'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre { font-family: var(--mono); font-size: 12px; }

/* ---- Layout ---- */

body { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

/* ---- Sidebar ---- */

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand a {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
}

.nav-links {
  list-style: none;
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}
.nav-links li a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  transition: color 0.15s, background 0.15s;
  border-radius: var(--radius);
  margin: 1px 0.5rem;
}
.nav-links li.active a,
.nav-links li a:hover {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}
.nav-links li.active a { color: var(--primary); }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 12px;
  color: var(--text-muted);
}
.username { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Page header ---- */

.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-header h2 {
  font-size: 1.4rem;
  font-weight: 600;
  flex: 1;
}

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}
.card-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.card-danger { border-color: rgba(239,68,68,0.3); }
.card-danger .card-header { background: rgba(239,68,68,0.05); }
.card > p, .card > .card-desc { padding: 0.75rem 1rem 0; margin: 0; }

/* ---- Tables ---- */

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface2);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table-compact td, .table-compact th { padding: 0.4rem 1rem; }
.row-disabled { opacity: 0.5; }
.row-lint td:first-child { border-left: 3px solid var(--warning); }

/* ---- Badges ---- */

.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: lowercase;
  letter-spacing: 0.02em;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-neutral { background: rgba(107,114,128,0.2); color: var(--text-muted); }

/* ---- Lint badges (inline below policy name) ---- */
.lint-badge {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 11px;
  font-weight: 500;
  border-radius: 3px;
  padding: 0.1em 0.4em;
}
.lint-error   { background: rgba(239,68,68,0.12); color: var(--danger); }
.lint-warning { background: rgba(245,158,11,0.12); color: var(--warning); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: 0.25rem 0.65rem; font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-full { width: 100%; justify-content: center; }
.btn-link {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 12px; padding: 0;
}
.btn-link:hover { color: var(--text); }

/* ---- Forms ---- */

.form-group {
  margin-bottom: 1rem;
  padding: 0 1rem;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  font-family: var(--font);
  font-size: 13px;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group select option { background: var(--surface); }
.form-row {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 200px; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1rem 0;
  padding: 0.5rem 0 1rem;
}
fieldset legend {
  margin-left: 1rem;
  padding: 0 0.25rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.form-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0 1rem 1rem;
}
.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.inline-form input, .inline-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.4rem 0.75rem;
  font-size: 13px;
}
.inline-form input:focus { outline: none; border-color: var(--primary); }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* ---- Alerts ---- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid;
  font-size: 13px;
}
.alert-success { background: rgba(34,197,94,0.1);  border-color: rgba(34,197,94,0.3);  color: var(--success); }
.alert-error    { background: rgba(239,68,68,0.1);  border-color: rgba(239,68,68,0.3);  color: var(--danger); }
.alert-warning  { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: var(--warning); }

/* ---- Stat grid ---- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-grid-2 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 1rem;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
}
.stat-card.stat-success { border-color: rgba(34,197,94,0.3); }
.stat-card.stat-danger  { border-color: rgba(239,68,68,0.3); }
.stat-card.stat-warning { border-color: rgba(245,158,11,0.3); }
.stat-card.stat-active  { border-color: rgba(99,102,241,0.4); }

/* ---- Attention section ---- */
.attention-item {
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--border);
  margin-bottom: 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.attention-item:last-child { margin-bottom: 0; }
.attention-danger  { border-color: var(--danger);  background: rgba(239,68,68,0.06); }
.attention-warning { border-color: var(--warning); background: rgba(245,158,11,0.06); }
.attention-list {
  margin: 0.35rem 0 0 1rem;
  padding: 0;
  list-style: disc;
  font-size: 13px;
  color: var(--text-muted);
}
.attention-list li { margin-bottom: 0.15rem; }
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 0.25rem;
  color: var(--text);
}
.stat-sub {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* ---- Two-column layout ---- */

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

/* ---- Detail list ---- */

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  padding: 1rem;
  align-items: start;
}
.detail-list dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding-top: 0.1rem;
}

/* ---- Tags / pills ---- */

.tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.1em 0.6em;
  font-size: 11px;
  color: var(--text-muted);
  margin: 1px;
}
.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
}
.tag-list li {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.15em 0.7em;
  font-size: 12px;
}

/* ---- Event list ---- */

.event-list {
  list-style: none;
  padding: 0.5rem 0;
}
.event-list li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.event-list li:last-child { border-bottom: none; }
.event-kind {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--primary);
  min-width: 180px;
}
.event-actor { color: var(--text-muted); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.event-time  { color: var(--text-muted); white-space: nowrap; }

/* ---- Misc helpers ---- */

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.muted { color: var(--text-muted); font-size: 12px; }
.field-hint { color: var(--text-muted); font-size: 12px; line-height: 1.6; margin-top: 0.75rem; padding: 0 1rem; }
.labels { font-size: 11px; color: var(--text-muted); max-width: 200px; }
.nowrap { white-space: nowrap; }
.actions { white-space: nowrap; }
.detail { font-size: 12px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.hash { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.small { font-size: 11px; }
.progress-text { font-size: 12px; color: var(--text-muted); }
.audit-meta {
  padding: 0.5rem 1rem;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}
.pagination-info { font-size: 12px; color: var(--text-muted); }
.filter-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.3rem 0.65rem;
  font-size: 12px;
}
.filter-form input:focus { outline: none; border-color: var(--primary); }
.code-block {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  margin-top: 0.5rem;
  color: var(--text-muted);
}
pre.artifact {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
details summary::-webkit-details-marker { color: var(--text-muted); }
.token-display {
  display: block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  cursor: text;
}

/* ---- Login page ---- */

body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
}
.login-card .form-group { padding: 0; }
.login-card .form-group input {
  width: 100%;
}
.login-card .btn { margin-top: 0.25rem; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
.form-hint {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Preview ---- */

.page-header-actions { display: flex; gap: 0.5rem; align-items: center; }

pre.artifact {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
  color: var(--text);
}
