* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
  background: #f3f2f1;
  color: #323130;
  min-height: 100vh;
}

/* --- Header (authenticated pages only) --- */
.app-header {
  background: #0078d4;
  color: white;
  padding: 0 1.5rem;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.app-header .brand {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: white;
}
.app-header .brand svg { width: 20px; height: 20px; }
.app-header nav { display: flex; align-items: center; gap: 0.25rem; }
.app-header nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.app-header nav a:hover { background: rgba(255,255,255,0.15); color: white; }
.app-header .user-name {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  margin-right: 0.5rem;
}

/* --- Login page layout (no header) --- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #fafafa;
}
.login-card {
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04);
  padding: 2.75rem 2.5rem;
  width: 100%;
  max-width: 440px;
  text-align: center;
}
.login-card .app-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.25rem;
  background: #0078d4;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card .app-icon svg { width: 28px; height: 28px; }
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #242424;
  margin-bottom: 0.5rem;
}
.login-card .subtitle {
  font-size: 0.9rem;
  color: #616161;
  margin-bottom: 2rem;
  line-height: 1.5;
}
.ms-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: #0078d4;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.7rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.ms-login-btn:hover { background: #106ebe; }
.ms-login-btn img, .ms-login-btn svg { width: 20px; height: 20px; }
.login-footer {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: #999;
}

/* --- Main content area --- */
.container { max-width: 820px; margin: 0 auto; padding: 1.5rem; }

/* --- Cards --- */
.card {
  background: white;
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}
.card h2 { margin-bottom: 1rem; color: #242424; font-size: 1.1rem; font-weight: 600; }

/* --- Badges --- */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.badge-success { background: #dff6dd; color: #107c10; }
.badge-error { background: #fde7e9; color: #a80000; }
.badge-info { background: #deecf9; color: #0078d4; }

/* --- Buttons --- */
.btn {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: #0078d4; color: white; border-color: #0078d4; }
.btn-primary:hover { background: #106ebe; border-color: #106ebe; }
.btn-secondary { background: white; color: #323130; border-color: #8a8886; }
.btn-secondary:hover { background: #f3f2f1; }
.btn-danger { background: #a80000; color: white; border-color: #a80000; }
.btn-danger:hover { background: #8b0000; }

/* --- Info grid --- */
.steps { list-style: none; padding: 0; }
.steps li { padding: 0.5rem 0; border-bottom: 1px solid #edebe9; font-family: 'Cascadia Code', Consolas, monospace; font-size: 0.85rem; }
.steps li:last-child { border-bottom: none; }
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: 0.5rem; }
.info-grid dt { font-weight: 600; color: #605e5c; font-size: 0.875rem; }
.info-grid dd { word-break: break-all; font-size: 0.875rem; }
pre { background: #faf9f8; border: 1px solid #edebe9; border-radius: 4px; padding: 1rem; overflow-x: auto; font-size: 0.85rem; white-space: pre-wrap; }

/* --- Search --- */
.search-box { display: flex; gap: 0.5rem; }
.search-box input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid #8a8886;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box input:focus {
  border-color: #0078d4;
  box-shadow: 0 0 0 1px #0078d4;
}

/* --- Answer box --- */
.answer-box {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: #f0f6ff;
  border-left: 3px solid #0078d4;
  border-radius: 4px;
}
.answer-box .answer-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: #0078d4;
}
.answer-box .answer-label svg { width: 16px; height: 16px; }
/* Markdown rendered inside answer */
.answer-content { line-height: 1.65; font-size: 0.9rem; color: #323130; }
.answer-content p { margin-bottom: 0.6rem; }
.answer-content p:last-child { margin-bottom: 0; }
.answer-content ul, .answer-content ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.answer-content li { margin-bottom: 0.25rem; }
.answer-content h1, .answer-content h2, .answer-content h3 { font-size: 1rem; font-weight: 600; margin: 0.75rem 0 0.35rem; color: #242424; }
.answer-content code { background: #e1dfdd; padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.85em; }
.answer-content pre { background: #faf9f8; padding: 0.75rem; border-radius: 4px; margin: 0.5rem 0; }
.answer-content pre code { background: none; padding: 0; }
.answer-content a { color: #0078d4; }
.answer-content strong { font-weight: 600; }

/* --- Results --- */
.result-item { padding: 0.875rem 0; border-bottom: 1px solid #edebe9; }
.result-item:last-child { border-bottom: none; }
.result-title { font-size: 1rem; font-weight: 600; color: #0078d4; text-decoration: none; }
.result-title:hover { text-decoration: underline; }
.result-url { font-size: 0.75rem; color: #107c10; margin: 0.2rem 0; word-break: break-all; }
.result-snippet { font-size: 0.85rem; color: #605e5c; line-height: 1.5; }

/* --- Details/collapsible --- */
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
code { background: #e1dfdd; padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.85rem; }

/* --- Loading spinner --- */
.loader { position: relative; width: 40px; height: 40px; margin: 0 auto; }
.loader-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2.5px solid transparent;
}
.loader-ring:nth-child(1) {
  border-top-color: #0078d4;
  animation: spin 1s ease-in-out infinite;
}
.loader-ring:nth-child(2) {
  border-right-color: #50a0e0;
  animation: spin 1.2s ease-in-out infinite reverse;
}
.loader-ring:nth-child(3) {
  inset: 5px; border-bottom-color: #82c0f0;
  animation: spin 0.8s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Sign-out button (styled as nav link) --- */
.signout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.signout-btn:hover { background: rgba(255,255,255,0.15); color: white; }

/* --- Inline utility for crawler buttons --- */
.inline-form { display: inline; }
.needs-login-btn { background: #d69e2e; }

/* --- Utility classes (avoid inline style attributes for CSP compliance) --- */
.hidden { display: none; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-half { margin-bottom: 0.5rem; }
.my-1 { margin: 1rem 0; }
.ml-half { margin-left: 0.5rem; }
.text-center { text-align: center; }
.text-error { color: #a80000; }
.inline-heading { display: inline; }

/* --- Search loading/empty states --- */
.search-loading-wrap { padding: 2rem; text-align: center; }
.loading-text { margin-top: 0.75rem; color: #605e5c; font-size: 0.85rem; }
.search-empty-wrap { padding: 2rem; text-align: center; color: #8a8886; font-size: 0.9rem; }

/* --- Admin section --- */
.admin-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.help-text { color: #605e5c; font-size: 0.85rem; line-height: 1.6; }

/* --- Crawl test --- */
.section-heading { margin: 1rem 0 0.5rem; }
.recommendation-box { background: #f0f9ff; border-left: 4px solid #2b6cb0; margin: 1rem 0; }
