:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e5eb;
  --text: #1c222b;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eaf0fe;
  --danger: #dc2626;
  --danger-light: #fdecec;
  --success: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}
.topbar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}

.topbar nav {
  display: flex;
  gap: 4px;
}

.topbar nav a {
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--accent-light); color: var(--accent); }

.topbar .user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}
.topbar .user-box .role-badge {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: #f3c9c9; }
.btn.danger:hover { background: var(--danger-light); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.container.narrow { max-width: 460px; padding-top: 80px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 14px; }
.subtitle { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 18px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=date], input[type=email], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-light);
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }

.form-msg { font-size: 13px; margin-top: 8px; }
.form-msg.error { color: var(--danger); }
.form-msg.success { color: var(--success); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.active { background: #e7f7ec; color: var(--success); }
.badge.inactive { background: #f2f2f3; color: var(--text-muted); }

.cat-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.cat-added { background: #e7f7ec; color: #16a34a; }
.cat-changed { background: #eaf0fe; color: #2563eb; }
.cat-fixed { background: #fff4e0; color: #b45309; }
.cat-removed { background: #fdecec; color: #dc2626; }
.cat-security { background: #f3e8fd; color: #7e22ce; }
.cat-deprecated { background: #f2f2f3; color: #4b5563; }

.project-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
}
.project-chip .swatch { width: 8px; height: 8px; border-radius: 50%; }

.entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.entry-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.entry-title { font-weight: 600; font-size: 15px; margin: 0 0 4px; }
.entry-desc { color: var(--text-muted); font-size: 14px; white-space: pre-wrap; margin: 4px 0 0; }
.entry-meta { color: var(--text-muted); font-size: 12.5px; margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.entry-meta strong { color: var(--text); font-weight: 600; }

.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}
.filter-bar .field { margin-bottom: 0; min-width: 170px; }
.chip-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-toggle button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
.chip-toggle button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 50px 20px;
}

.token-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}

.hint { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); padding: 22px;
  max-width: 460px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}

code.inline {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .container { padding: 20px 14px 50px; }
}
