@font-face {
  font-family: "Geist";
  src: url("/assets/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --surface: #f7f7f5;
  --ink: #16181b;
  --ink-2: #2b2e33;
  --muted: #62666d;
  --placeholder: #8A8A84;
  --border: #e6e7ea;
  --accent: #1f5c4e;
  --accent-hover: #184a3f;
  --accent-soft: #e8f0ed;
  --card-pad-top: 24px;
  --card-pad-x: 16px;
  --card-pad-bottom: 24px;
  --content-max: 1200px;
  --page-gutter: 1.25rem;
  --radius: 0.625rem;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.04), 0 1px 3px rgb(16 24 40 / 0.06);
  --shadow-lg: 0 1px 2px rgb(16 24 40 / 0.04), 0 12px 32px -8px rgb(16 24 40 / 0.12);
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (min-width: 640px) {
  :root {
    --card-pad-top: 40px;
    --card-pad-x: 40px;
    --card-pad-bottom: 40px;
  }
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Entra sign-in gating: hide page body until MSAL completes */
body:not(.authed) main,
body:not(.authed) footer,
body:not(.authed) .header-auth {
  display: none;
}

body.authed .auth-gate {
  display: none;
}

.is-hidden {
  display: none !important;
}

/* Sticky site header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 4rem;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0.625rem var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
}

.header-brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: 0.375rem;
}

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.brand img {
  display: block;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-wordmark {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  border-radius: 999px;
  background: #fff7e0;
  border: 1px solid #d9a514;
  color: #6b4e00;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
}

.header-nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
}

.header-nav-link:hover {
  color: var(--ink);
}

.header-nav-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.3125rem 0.75rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 500;
}

.account-menu-wrap {
  display: none;
}

.avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #c5dad2;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.avatar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 200px;
  padding: 0.25rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}

.account-menu-label {
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

.account-menu-item {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.875rem;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu-item:hover,
.account-menu-item:focus-visible {
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.account-menu-item:focus-visible {
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Auth gate status */
.auth-gate {
  width: 100%;
  max-width: 460px;
  margin: 4rem auto;
  padding: 0 1rem;
}

.auth-gate-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  text-align: center;
}

.auth-gate-title {
  margin: 0 0 0.5rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
}

.auth-gate-message {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.auth-gate-error {
  color: #991b1b;
}

.auth-gate-actions {
  margin-top: 1.25rem;
}

/* Main layout & cards */
.page-main,
.page-main-narrow {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem var(--page-gutter) 3.5rem;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--card-pad-top) var(--card-pad-x) var(--card-pad-bottom);
}

.card + .card {
  margin-top: 1.5rem;
}

.card-header {
  margin-bottom: 1.75rem;
}

h1 {
  margin: 0 0 0.375rem;
  font-size: 1.625rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--ink);
}

.subtitle {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Form sections & fields */
.form-section {
  padding-top: 1.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.form-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.section-heading {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.section-desc {
  margin: 0 0 1.125rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

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

.field {
  margin-bottom: 1rem;
}

.field-grid .field {
  margin-bottom: 0;
}

.field + .field-grid,
.field-grid + .field,
.field-grid + .field-grid {
  margin-top: 1rem;
}

label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
}

.required-mark {
  color: var(--accent);
  font-weight: 600;
  margin-left: 0.125rem;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  min-height: 44px;
  padding: 0.5625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.field-hint {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}


code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 0.25rem;
  color: var(--ink-2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--ink-2);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface);
  color: var(--ink);
}

.btn-sm {
  min-height: 36px;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
}

.form-actions {
  margin-top: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

@media (max-width: 639px) {
  .header-inner {
    padding: 0.5rem 16px;
    flex-wrap: nowrap;
    gap: 0.5rem;
  }

  .header-brand-group {
    flex: 1 1 auto;
    gap: 0.25rem 0.5rem;
  }

  .brand-wordmark {
    font-size: 0.9375rem;
  }

  .demo-badge {
    font-size: 0.6875rem;
    padding: 0.125rem 0.5rem;
  }

  .header-auth {
    flex-shrink: 0;
    margin-left: auto;
  }

  .header-auth .user-chip,
  .header-auth .btn,
  .header-auth .header-nav-link {
    display: none;
  }

  .account-menu-wrap {
    display: block;
    position: relative;
  }

  .page-main {
    padding: 1.25rem 16px 2.5rem;
  }

  .form-actions .btn-primary,
  .result-actions .btn-primary {
    width: 100%;
  }
}

/* Alerts */
.alert {
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-info {
  background: var(--accent-soft);
  border-color: #c5dad2;
  color: #16443a;
}

.alert-warn {
  background: #fff7e0;
  border-color: #e6c66b;
  color: #6b4e00;
}

/* Collapsed disclosure */
.data-details {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.data-details summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-2);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-radius: 0.375rem;
}

.data-details summary::-webkit-details-marker {
  display: none;
}

.data-details summary::after {
  content: "+";
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

.data-details[open] summary::after {
  content: "\2212";
}

.data-details summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.details-body {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: var(--ink-2);
}

.details-body p {
  margin: 0 0 0.625rem;
}

.details-body p:last-child {
  margin-bottom: 0;
}

.details-list {
  margin: 0.5rem 0 0;
  padding-left: 1.125rem;
}

.details-list li + li {
  margin-top: 0.375rem;
}

/* Result page & replaced card */
.result-header {
  margin-bottom: 1rem;
}

.result-title-row {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
}

.result-header h1,
.result-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.result-header .subtitle {
  margin-top: 0.5rem;
}

.result-icon {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  margin-top: calc((28px * 1.25 - 24px) / 2);
}

.result-icon-ok {
  color: var(--accent);
}

.result-icon-err {
  color: #b91c1c;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
}

.status-pill-ok {
  background: var(--accent-soft);
  border-color: #c5dad2;
  color: #16443a;
}

.status-pill-err {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.result-dl,
.kv-list {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.75rem 1.25rem;
  margin: 1.25rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.result-dl dt,
.kv-list dt {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

.result-dl dd,
.kv-list dd {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--ink);
  word-break: break-word;
}

@media (max-width: 540px) {
  .result-dl,
  .kv-list {
    grid-template-columns: 1fr;
    gap: 0.25rem 0;
  }

  .result-dl dd,
  .kv-list dd {
    margin-bottom: 0.75rem;
  }
}

.result-actions {
  margin-top: 1.25rem;
}

/* Settings identity & list */
.kv-list {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0.25rem;
}

.identity-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
}

.identity-label {
  color: var(--muted);
  font-weight: 500;
}

.identity-value {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.625rem;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}

.identity-name {
  color: var(--ink);
}

.identity-email {
  color: var(--muted);
}

/* Footer */
.site-footer {
  margin-top: auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.footer-inner {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* In-page result swap: hide the site footer so the result card isn't followed by a duplicate footer. */
body:has(#result) .site-footer {
  display: none;
}
