:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3ea;
  --text: #111827;
  --muted: #6b7280;
  --subtle: #9ca3af;
  --accent: #2563eb;
  --accent-soft: #eaf1ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #047857;
  --success-soft: #d1fae5;
  --warning: #a16207;
  --warning-soft: #fef3c7;
  --sidebar: #111827;
  --sidebar-muted: #9ca3af;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #fff;
}
textarea { min-height: 76px; resize: vertical; }
label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #101827;
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; margin-bottom: 14px; }
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
}
.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  padding: 0 8px 18px;
}
#sidebar-nav {
  display: grid;
  gap: 4px;
  flex: 1;
}
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: var(--radius);
  color: var(--sidebar-muted);
  background: transparent;
  text-align: left;
}
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.main { min-width: 0; }
.topbar {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar h2 { margin: 0; font-size: 19px; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.actor-chip {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}
.content { padding: 24px 28px 40px; }
.toolbar {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 14px;
}
.filters input, .filters select { width: 180px; }
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.metric .value { font-size: 24px; font-weight: 800; }
.metric .label { color: var(--muted); font-size: 12px; }
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  background: #f9fafb;
  font-size: 12px;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
}
.badge-active { color: var(--success); background: var(--success-soft); }
.badge-expired, .badge-revoked { color: var(--danger); background: var(--danger-soft); }
.badge-not-started { color: var(--warning); background: var(--warning-soft); }
.badge-not-found { color: var(--muted); background: #f3f4f6; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-weight: 700;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--sidebar-muted); border: 1px solid rgba(255,255,255,.12); }
.btn-sm { padding: 5px 8px; font-size: 12px; }
.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: #f3f4f6;
  color: var(--muted);
}
.modal[hidden], .toast[hidden], [hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, .55);
}
.modal-panel {
  position: relative;
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
}
.modal-header, .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-footer {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.modal-header h3 { margin: 0; }
.modal-body { padding: 18px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid .wide { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 13px; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.toast.error { background: var(--danger); }
.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  max-height: 280px;
  overflow: auto;
}
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; }
  #sidebar-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .filters input, .filters select { width: 100%; }
}
