:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --warning-text: #92400e;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100vh;
  margin: 0;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.app-nav .brand {
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.04em;
  line-height: 1;
}

.app-nav .brand:hover { color: var(--accent-hover); }

.app-nav .nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-nav .nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.app-nav .nav-links a:hover { color: var(--text); background: var(--surface-hover); }
.app-nav .nav-links a.active { color: var(--accent); background: var(--accent-light); }

/* ── Main content ── */
.app-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* ── Footer ── */
.app-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  background: var(--surface);
}

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.4rem; letter-spacing: -0.03em; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.4rem; letter-spacing: -0.02em; }
h3 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }

.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.page-desc {
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.6;
  font-size: 1rem;
}

/* ── Links ── */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ── Buttons ── */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1.1rem;
  transition: all 0.15s ease;
  letter-spacing: -0.01em;
  line-height: 1.5;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-outline-secondary {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.btn-outline-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border);
}

.btn-sm { font-size: 0.8rem; padding: 0.35rem 0.75rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  transition: box-shadow 0.15s ease;
}

.card:hover { box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10); }

.card-body { padding: 1.1rem 1.25rem; }
.card-title { font-size: 0.9rem; font-weight: 600; margin-bottom: 0; }

/* ── Tool list (index page) ── */
.tool-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-list li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.tool-list li a::after {
  content: "→";
  color: var(--muted);
  transition: transform 0.15s, color 0.15s;
  font-size: 1rem;
  flex-shrink: 0;
}

.tool-list li a:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-list li a:hover::after {
  transform: translateX(4px);
  color: var(--accent);
}

/* ── pre / code ── */
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  background: var(--surface-hover);
  color: var(--text);
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
}

/* ── Badges ── */
.badge-pass { background-color: var(--success); color: #fff; border-radius: 6px; }
.badge-fail { background-color: var(--danger); color: #fff; border-radius: 6px; }
.badge-neutral { background: var(--surface-hover); border: 1px solid var(--border); color: var(--muted); }

/* ── Probe cards (chaos page) ── */
.probe-card {
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ── Spinner ── */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-border {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border: 0.18em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: -0.125em;
}


.form-label-upper {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
  display: block;
}

/* ── Alerts ── */
.alert-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
  border-radius: 10px;
}

.alert-danger {
  background-color: #fef2f2;
  border-color: #fca5a5;
  color: var(--danger);
  border-radius: 10px;
}

.alert-success {
  background-color: #f0fdf4;
  border-color: #86efac;
  color: var(--success);
  border-radius: 10px;
}

/* ── Mono token display ── */
.token-box {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  word-break: break-all;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  color: var(--text);
}

/* ── iframe container ── */
.iframe-wrapper {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.iframe-full {
  width: 100%;
  height: 600px;
  display: block;
  border: none;
}

/* ── LWC container ── */
.lwc-container {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  min-height: 400px;
  padding: 1rem;
}

/* ── API endpoint table ── */
.endpoint-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.endpoint-table th {
  background: var(--surface-hover);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.65rem 1rem;
  border: 1px solid var(--border);
  text-align: left;
}

.endpoint-table td {
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  vertical-align: middle;
  color: var(--muted);
  background: var(--surface);
}

.endpoint-table td:nth-child(2) {
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.85rem;
}

.endpoint-table tr:hover td { background: var(--surface-hover); }

.method-badge {
  font-family: "SFMono-Regular", monospace;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
}

.method-get { background: #dcfce7; color: #15803d; }
.method-post { background: var(--accent-light); color: var(--accent); }

/* ── Summary bar (chaos) ── */
#summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

/* ── Alert base ── */
.alert {
  padding: 0.75rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.alert-link { font-weight: 600; color: inherit; }

/* ── Badge base ── */
.badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  line-height: 1;
  white-space: nowrap;
  vertical-align: baseline;
}

.bg-secondary { background-color: var(--muted); color: #fff; }
.text-secondary { color: var(--muted); }
.text-sm { font-size: 0.875rem; }

/* ── Form control base ── */
.form-control {
  display: block;
  width: 100%;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.55rem 0.85rem;
  line-height: 1.5;
  appearance: none;
}

.form-control:focus {
  outline: none;
  background-color: var(--surface);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-control::placeholder { color: var(--muted); }

/* ── Grid (chaos results) ── */
.row { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.g-3 { gap: 1rem; }
.col-12, .col-lg-6 { min-width: 0; }

@media (min-width: 992px) {
  .row { grid-template-columns: 1fr 1fr; }
}

/* ── Flex utilities ── */
.d-flex { display: flex; }
.d-none { display: none !important; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.justify-content-between { justify-content: space-between; }
.flex-shrink-0 { flex-shrink: 0; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.h-100 { height: 100%; }

/* ── Spacing utilities ── */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.ms-2 { margin-left: 0.5rem; }
.p-0 { padding: 0; }

/* ── Max-width utilities ── */
.mw-560 { max-width: 560px; }

/* ── Image utilities ── */
.img-fluid { max-width: 100%; border-radius: 8px; display: block; }

/* ── Headless identity ── */
#form-container, #password-container { max-width: 420px; }
#password-container { display: none; }
#message, #newPasswordMessage { font-size: 0.875rem; }

/* ── Mobile ── */
@media (max-width: 640px) {
  .app-main { padding: 1.5rem 1rem 3rem; }
  .app-nav { padding: 0 1rem; }
  h1 { font-size: 1.4rem; }
}

/* ── SFDC Pulse Feed ── */

body.pulse-page {
  background: #f4f6f9;
}

.pulse-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid #d8dde6;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
}

.pulse-brand {
  font-weight: 800;
  font-size: 1.25rem;
  color: #0070d2;
  letter-spacing: -0.03em;
}

#feed-container {
  max-width: 600px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  background: #ffffff;
  border: 1px solid #d8dde6;
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.post-category {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0070d2;
  background: #e8f4ff;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  align-self: flex-start;
}

.post-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #16213a;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.post-summary {
  font-size: 0.9rem;
  color: #444f60;
  line-height: 1.65;
  margin: 0;
}

.code-wrapper,
.post-card pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  margin: 0;
}

.post-card pre {
  white-space: pre;
  word-break: normal;
  font-size: 0.8rem;
  max-height: none;
  overflow-y: visible;
  background: transparent;
  border: none;
  padding: 0;
}

.post-source {
  font-size: 0.8rem;
  font-weight: 500;
  color: #0070d2;
  text-decoration: none;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.post-source:hover {
  text-decoration: underline;
  color: #005fb2;
}

.feed-end {
  text-align: center;
  color: #8a98a8;
  font-size: 0.85rem;
  padding: 2rem 0 1rem;
}

@media (max-width: 640px) {
  #feed-container {
    padding: 0 0.75rem;
    margin-top: 1rem;
  }

  .post-card {
    padding: 1rem 1.1rem;
    border-radius: 10px;
  }
}

/* ── Metadata Explorer ── */

#meta-layout {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.meta-left-panel  { flex: 0 0 260px; min-width: 0; }
.meta-right-panel { flex: 1; min-width: 0; }

#object-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 620px;
  overflow-y: auto;
}
#object-loading {
  padding: 1.25rem 1rem;
  color: var(--muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
#object-count       { font-size: 0.75rem; color: var(--muted); margin-top: 0.4rem; }
#fields-placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}
#fields-title { margin: 0; font-size: 1rem; }
#fields-count { font-size: 0.8rem; color: var(--muted); }

.meta-card-overflow { overflow: hidden; }
.meta-fields-table  { font-size: 0.83rem; table-layout: fixed; }

.meta-fields-table th:nth-child(1),
.meta-fields-table td:nth-child(1) { width: 28%; }

.meta-fields-table th:nth-child(2),
.meta-fields-table td:nth-child(2) { width: 28%; }

.meta-fields-table th:nth-child(3),
.meta-fields-table td:nth-child(3) { width: 22%; overflow: hidden; }

.meta-fields-table th:nth-child(4),
.meta-fields-table td:nth-child(4) { width: 10%; }

.meta-fields-table th:nth-child(5),
.meta-fields-table td:nth-child(5) { width: 12%; }

.meta-fields-table td:nth-child(3) .badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}
.meta-api-name      { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.8rem; }
.meta-muted         { color: var(--muted); }
.meta-empty         { padding: 1rem; color: var(--muted); font-size: 0.85rem; }
.meta-load-error    { color: var(--danger); font-size: 0.85rem; }

.obj-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem;
  color: var(--text);
  font-family: inherit;
  transition: background 0.1s;
}
.obj-item:hover         { background: var(--surface-hover); }
.obj-item--active       { background: var(--accent-light); color: var(--accent); }
.obj-item--active:hover { background: var(--accent-light); }
.obj-item__label        { display: block; font-weight: 500; }
