/* Cards, dialogs and the pieces inside them. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card-list { display: flex; flex-direction: column; gap: 20px; }
.card-slot:empty { display: none; }
.card-slot--banners { display: flex; flex-direction: column; gap: 12px; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.card-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.eyebrow { font-size: 12px; color: var(--text-muted); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; }
.card-title { font-size: 19px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
h1.card-title { font-family: var(--font-serif); font-size: 30px; letter-spacing: -0.01em; }

.card-footer { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-footer .status-note { flex: 1 1 220px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
}

.card-head .pill, .run-head .pill, .dialog-head .pill { align-self: center; }
.pill--success { background: var(--success-bg); color: var(--success-text); }
.pill--warning { background: var(--warning-bg); color: var(--warning-text); }
.pill--danger { background: var(--danger-bg); color: var(--danger-text); }
.pill--neutral { background: var(--surface-neutral); color: var(--text-strong); }

/* Callouts carry every state: revoked, disconnected, paused, new library, failed files, errors. */
.callout { border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.callout--warning { background: var(--warning-bg); color: var(--warning-strong); }
.callout--danger { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.callout--neutral { background: var(--surface-muted); color: var(--text-strong); border: 1px solid var(--border); }
.callout--success { background: var(--success-bg); color: var(--success-text); }
.callout:has(> .callout-body) { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px 16px; flex-wrap: wrap; }
.callout-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 280px; }
.callout-title { font-weight: 600; overflow-wrap: anywhere; }
.callout-detail { font-size: 13px; }
.callout-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.callout-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.callout .button--secondary { background: var(--surface); }

/* Facts grid on the card and in Manage. */
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; margin: 0; }
.fact { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact--wide { grid-column: span 2; }
.fact dt { font-size: 12px; color: var(--text-muted); }
.fact dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.fact dd.fact-secondary { font-size: 13px; color: var(--text-muted); }

/* Sync progress and the last run. */
.sync { display: flex; flex-direction: column; gap: 10px; }
.sync-title { font-size: 14px; font-weight: 600; color: var(--text-strong); }
.sync-meta { font-size: 13px; color: var(--text-strong); overflow-wrap: anywhere; }
.sync-error { font-size: 13px; color: var(--danger-text); overflow-wrap: anywhere; }
.progress-row { display: flex; flex-direction: column; gap: 6px; }
.progress-labels { display: flex; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; font-size: 13px; color: var(--text-strong); }
.progress-name { font-weight: 500; overflow-wrap: anywhere; }

.progress-bar {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 4px;
  background: var(--track);
  overflow: hidden;
  -webkit-appearance: none;
  appearance: none;
}

.progress-bar::-webkit-progress-bar { background: var(--track); border-radius: 4px; }
.progress-bar::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.progress-bar::-moz-progress-bar { background: var(--accent); border-radius: 4px; }

/* The empty state. */
.empty-state { align-items: center; text-align: center; padding: 56px 40px; gap: 12px; }

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-title { font-family: var(--font-serif); font-weight: 600; font-size: 22px; }
.empty-body { color: var(--text-muted); max-width: 440px; }
.empty-state .button { margin-top: 8px; }

/* Dialogs. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dialog {
  width: min(640px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-dialog);
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-dialog);
}

.dialog:focus { outline: none; }
.dialog-head { display: flex; flex-direction: column; gap: 4px; }
.dialog-head--split { flex-direction: row; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.dialog-title { font-family: var(--font-serif); font-weight: 600; font-size: 24px; line-height: 1.2; }
.dialog-intro { font-size: 14px; color: var(--text-strong); line-height: 1.5; }
.dialog-head .dialog-intro { color: var(--text-muted); }
.dialog-form { display: flex; flex-direction: column; gap: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.dialog-actions .status-note { margin-right: auto; }

/* Add a connector: the catalog of sources. */
.sources { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.source {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-strong);
  font: inherit;
  text-align: left;
}

.source:disabled { cursor: not-allowed; }
.source--live { background: var(--surface); border: 2px solid var(--accent); padding: 15px; color: var(--text); cursor: pointer; }
.source--live:hover { background: var(--chip); }

.source-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--surface-neutral);
  color: var(--text-quiet);
  display: flex;
  align-items: center;
  justify-content: center;
}

.source--live .source-icon { background: var(--accent-tint); color: var(--accent); }
.source-text { display: flex; flex-direction: column; gap: 4px; }
.source-name { font-size: 15px; font-weight: 600; }
.source-meta { font-size: 13px; color: var(--text-quiet); }
.source--live .source-meta { color: var(--text-muted); }

/* Connect SharePoint: chips, the explainer and the password note. */
.chips { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chips:empty { display: none; }
.chip { display: inline-flex; gap: 6px; align-items: baseline; max-width: 100%; padding: 6px 12px; border-radius: var(--radius-pill); background: var(--chip); font-size: 13px; }
.chip-label { color: var(--chip-label); }
.chip-value { font-weight: 600; overflow-wrap: anywhere; }

.explainer { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.explainer-title { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.need { display: flex; flex-direction: column; gap: 2px; }
.need-title { font-size: 14px; font-weight: 500; }
.need-detail { font-size: 13px; color: var(--text-muted); }
.explainer-note { font-size: 13px; color: var(--text-strong); border-top: 1px solid var(--border); padding-top: 12px; }
.lock-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-strong); }
.lock-note .icon { flex-shrink: 0; margin-top: 2px; }

/* Libraries QRA will read. */
.site-summary { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--ground); border-radius: 10px; color: var(--accent); }
.site-summary .icon { flex-shrink: 0; }
.site-summary-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--text); }
.site-summary-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.site-summary-address { font-size: 12px; color: var(--chip-label); }
.library-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.library-group legend { padding: 0; margin-bottom: 8px; }
.library-options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.library-option {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.library-option:has(.checkbox:checked) { border: 2px solid var(--accent); padding: 9px 15px; }
.library-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.library-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.library-meta { font-size: 13px; color: var(--text-muted); }
.info-box { padding: 12px 16px; border-radius: 10px; background: var(--chip); color: var(--info-text); font-size: 13px; line-height: 1.5; }

/* Connecting: the checklist of real results. */
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; align-items: center; gap: 12px; min-height: 36px; font-size: 15px; }
.step--waiting { color: var(--text-quiet); }
.step-text { overflow-wrap: anywhere; min-width: 0; }
.step-marker { width: 24px; height: 24px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.step-marker--done { background: var(--success-solid); color: #FFFFFF; }
.step-marker--active { color: var(--accent); }
.step-marker--waiting { width: 22px; height: 22px; margin: 1px; border: 1px solid var(--border-control); }
.step-marker--failed { background: var(--danger-text); color: #FFFFFF; }
.spin { animation: spin 0.9s linear infinite; transform-origin: 50% 50%; }

@keyframes spin { to { transform: rotate(360deg); } }

/* The API's help: who, steps, an approval link and copyable Graph requests. */
.help { display: flex; flex-direction: column; gap: 12px; }
.help-who { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.help-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.help-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.help-requests { display: flex; flex-direction: column; gap: 10px; }
.help-heading { font-size: 13px; font-weight: 600; }
.request { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.request-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.request-label { font-size: 14px; font-weight: 500; }
.request-body { margin: 0; padding: 10px 12px; border-radius: var(--radius-control); background: var(--ground); color: var(--text-strong); font-size: 12px; white-space: pre-wrap; }
.copy-field { display: flex; flex-direction: column; gap: 6px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-value { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--radius-control); background: var(--ground); color: var(--text-strong); font-size: 12px; }

/* Sign in with Microsoft, and the notices above the first view. */
.sign-in { max-width: 640px; }
.sign-in-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.notices { display: flex; flex-direction: column; gap: 12px; }
.callout .copy-value { background: var(--surface); }

/* Manage: the back link, the panels, library rows and runs. */
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: var(--target); font-size: 14px; font-weight: 500; text-decoration: none; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 24px 28px; display: flex; flex-direction: column; gap: 14px; }
.panel-title { font-family: var(--font-serif); font-weight: 600; font-size: 22px; }
.panel-intro { font-size: 14px; color: var(--text-muted); }
.library-rows, .run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.library-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border); }
.library-row:first-child { border-top: 0; padding-top: 0; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.run { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-top: 1px solid var(--border); }
.run:first-child { border-top: 0; padding-top: 0; }
.run-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.run-when { font-weight: 500; }
.run-meta { font-size: 13px; color: var(--text-strong); overflow-wrap: anywhere; }
.run-error { font-size: 13px; color: var(--danger-text); overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .card, .panel { padding: 20px 16px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  .fact--wide { grid-column: auto; }
  .empty-state { padding: 40px 20px; }
  .dialog { padding: 20px 16px; }
}

@media (max-width: 560px) {
  .sources { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
}
