/* Shared */
body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; }

.page {
  max-width: 56rem;
  margin: 1rem auto;
  padding: 0 1rem 2rem;
}
a { color: #0563c1; }
a:hover { text-decoration: underline; }
code { background: #f0f0f0; padding: 0.15em 0.4em; border-radius: 3px; font-size: 0.9em; }

.topbar {
  background: linear-gradient(90deg, #0b3a7a, #1976d2);
  color: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.12);
}
.topbar-inner {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.brand {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}
.brand:hover { text-decoration: none; background: rgba(255,255,255,0.12); }
.navlink {
  color: rgba(255,255,255,0.92);
  text-decoration: none;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
}
.navlink:hover { text-decoration: none; background: rgba(255,255,255,0.12); }

.profile { position: relative; }
.profile-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.55rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
}
.profile-summary::-webkit-details-marker { display: none; }
.profile-summary:hover { background: rgba(255,255,255,0.14); }
.profile-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 99px;
  background: #8ef0ff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.12) inset;
}
.profile-label {
  max-width: 18rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 700;
  font-size: 0.9rem;
}
.profile-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  width: min(28rem, calc(100vw - 2rem));
  background: #fff;
  color: #111;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 0.75rem;
  z-index: 50;
}
.profile-row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.75rem;
  padding: 0.3rem 0.2rem;
  align-items: baseline;
}
.profile-k { color: #555; font-size: 0.85rem; font-weight: 700; text-transform: lowercase; }
.profile-v { font-size: 0.92rem; }
.profile-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #eee;
  font-weight: 800;
  font-size: 0.85rem;
  color: #333;
  letter-spacing: 0.02em;
}
.profile-roles { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.profile-roles li {
  padding: 0.3rem 0.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.profile-roles li .role-label { min-width: 0; }

.profile-actions { margin-top: 0.6rem; display: flex; justify-content: flex-end; }
.profile-actions { flex-wrap: wrap; gap: 0.4rem; }

.profile-v { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #f6f8fb;
  color: #0b3a7a;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 1rem;
}
.icon-btn:hover { background: #eef4ff; border-color: rgba(25,118,210,0.35); }
.icon-btn-primary {
  background: rgba(25,118,210,0.10);
  border-color: rgba(25,118,210,0.35);
  color: #0b3a7a;
}
.icon-btn-danger {
  background: rgba(200,0,0,0.06);
  border-color: rgba(200,0,0,0.20);
  color: #7a0b0b;
}

/* Icon tooltips (consistent across browsers) */
.icon-tip {
  position: relative;
}
.icon-tip::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.45rem;
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.25);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  z-index: 60;
}
.icon-tip:hover::after,
.icon-tip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.btn {
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  margin-right: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  font-size: 0.95rem;
}
.btn:hover { background: #e8e8e8; }
.btn-primary { background: #1976d2; color: #fff; border-color: #1976d2; }
.btn-primary:hover { background: #1565c0; }
.btn:disabled, .btn[disabled] { background: #ccc; color: #888; border-color: #bbb; cursor: not-allowed; pointer-events: none; }

/* Callback (role picker) */
.role-list { list-style: none; padding: 0; }
.role-list li { margin: 0.5rem 0; padding: 0.75rem; background: #f5f5f5; border-radius: 6px; }
.role-list label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
#result { margin-top: 1rem; padding: 1rem; background: #e8f5e9; border-radius: 6px; white-space: pre-wrap; word-break: break-all; display: none; }
#result.error { background: #ffebee; }
#result pre { margin: 0; font-size: 0.85rem; }

/* Admin */
.form-panel { display: none; margin-top: 1rem; padding: 1rem; border: 1px solid #ccc; border-radius: 6px; }
.form-panel label { display: block; margin-bottom: 0.25rem; }
.role-list li { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; }
.role-list a { margin-right: 0.5rem; }
.policy-json { font-family: ui-monospace, monospace; font-size: 0.85rem; width: 100%; min-height: 120px; }
.error { color: #c00; }
.muted { color: #666; }
.success { color: #2e7d32; }
.table { border-collapse: collapse; width: 100%; }
.table th, .table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #eee; }
.table th { font-weight: 600; }
.form-panel.form-panel-visible { display: block; }

/* Console */
.tree { margin: 0.5rem 0; padding: 0.5rem; background: #f9f9f9; border-radius: 4px; }
.tree ul { list-style: none; padding-left: 1rem; }
.tree li { margin: 0.25rem 0; }
.tree .prefix { cursor: pointer; }
.tree .obj { display: flex; justify-content: space-between; align-items: center; }
.breadcrumb { margin-bottom: 0.5rem; font-size: 0.9rem; }
.breadcrumb a { margin-right: 0.25rem; }
.upload-area { margin-top: 1rem; display: flex; align-items: center; gap: 0.5rem; }
input[type="file"] { margin-right: 0.5rem; }

.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid #ccc;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
