:root {
  --nhs-blue: #005eb8;
  --nhs-dark-blue: #003087;
  --nhs-pale-blue: #e8f1fb;
  --ink: #1a1f2b;
  --ink-muted: #5a6472;
  --border: #d7dde5;
  --bg: #ffffff;
  --bg-subtle: #f7f9fb;
  --red: #b30000;
  --green: #2e7d32;
  --amber: #8a6d00;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

/* Elements toggled via the `hidden` attribute must actually hide, even when a class on the
   same element sets its own `display` (e.g. .error-box uses display:flex when shown) —
   author rules of equal specificity otherwise beat the UA stylesheet's [hidden] rule. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

header.app-header {
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.app-header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--nhs-dark-blue);
}

.badge {
  display: inline-block;
  background: var(--nhs-pale-blue);
  color: var(--nhs-dark-blue);
  border: 1px solid var(--nhs-blue);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.data-statement {
  background: var(--nhs-pale-blue);
  border: 1px solid var(--nhs-blue);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
  font-size: 0.92rem;
  color: var(--ink);
}

.data-statement strong {
  color: var(--nhs-dark-blue);
}

section {
  margin-bottom: 32px;
}

h2 {
  font-size: 1.05rem;
  color: var(--nhs-dark-blue);
  margin: 0 0 12px;
}

.sample-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  padding: 8px 14px;
  font-size: 0.88rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover {
  background: var(--bg-subtle);
  border-color: var(--nhs-blue);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--nhs-blue);
  color: #fff;
  border-color: var(--nhs-blue);
  font-weight: 600;
  padding: 11px 22px;
  font-size: 0.95rem;
}

.btn-primary:hover {
  background: var(--nhs-dark-blue);
  border-color: var(--nhs-dark-blue);
}

.btn-secondary {
  background: #fff;
  color: var(--nhs-blue);
  border-color: var(--nhs-blue);
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 220px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

textarea:focus, button:focus {
  outline: 2px solid var(--nhs-blue);
  outline-offset: 1px;
}

.pasted-text-view {
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.9rem;
  background: var(--bg-subtle);
  max-height: 320px;
  overflow-y: auto;
}

.pasted-text-view mark {
  background: #ffe28a;
  border-radius: 3px;
  padding: 0 2px;
}

.action-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.hint {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.error-box {
  background: #fdecea;
  border: 1px solid #f2b8b5;
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-top: 14px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.results-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.completeness {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.completeness-label {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.bar-track {
  background: #e2e7ed;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s ease;
}

.field-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 4px 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.field-row:last-child {
  border-bottom: none;
}

.field-row:hover {
  background: var(--bg-subtle);
}

.field-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.field-value {
  font-size: 0.92rem;
  grid-column: 2;
}

.field-value.not-found {
  color: var(--red);
  font-weight: 600;
}

.field-source {
  grid-column: 2;
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-style: italic;
}

.chase-box {
  margin-top: 16px;
}

.chase-output {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--bg-subtle);
}

#print-agenda h1 {
  font-size: 1.3rem;
  color: var(--nhs-dark-blue);
  margin: 0 0 4px;
}

#print-agenda .meta {
  font-size: 0.85rem;
  margin-bottom: 4px;
}

#print-agenda .attendees {
  font-size: 0.85rem;
  margin: 12px 0;
}

#print-agenda table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 0.82rem;
}

#print-agenda th,
#print-agenda td {
  border: 1px solid #999;
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
}

#print-agenda th {
  background: var(--nhs-pale-blue);
  color: var(--nhs-dark-blue);
}

#print-agenda footer {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}

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

footer.app-footer {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding-top: 20px;
  color: var(--ink-muted);
  font-size: 0.82rem;
  text-align: center;
}

.empty-state {
  color: var(--ink-muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

@media (max-width: 600px) {
  .field-row {
    grid-template-columns: 1fr;
  }
  .field-value, .field-source {
    grid-column: 1;
  }
}

/* ---- Meeting details panel ---- */

.meeting-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--bg-subtle);
}

.meeting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

.field input,
.field textarea {
  font-weight: 400;
  font-family: inherit;
  font-size: 0.92rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.field-wide {
  margin-top: 16px;
}

.attendees-textarea {
  min-height: 90px;
  resize: vertical;
}

/* ---- Agenda list ---- */

.btn-danger {
  background: #fff;
  color: var(--red);
  border-color: var(--red);
  font-weight: 600;
}

.btn-danger:hover {
  background: #fdecea;
}

.agenda-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
  transition: background-color 1.4s ease, border-color 1.4s ease;
}

.agenda-row-flash {
  background-color: var(--nhs-pale-blue);
  border-color: var(--nhs-blue);
}

.agenda-row-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--bg);
}

.agenda-row-header:hover {
  background: var(--bg-subtle);
}

.agenda-row-num {
  font-weight: 700;
  color: var(--nhs-dark-blue);
  min-width: 22px;
  text-align: center;
}

.agenda-reorder {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.btn-icon {
  border: none;
  background: transparent;
  padding: 2px 6px;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--ink-muted);
}

.btn-icon:hover {
  color: var(--nhs-blue);
  background: transparent;
  border-color: transparent;
}

.agenda-row-summary {
  flex: 1 1 160px;
  min-width: 0;
}

.agenda-row-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-row-question {
  font-size: 0.82rem;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .agenda-row-summary {
    flex-basis: 100%;
    order: 10;
  }
  .agenda-row-name,
  .agenda-row-question {
    white-space: normal;
  }
}

.status-select {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.status-ready {
  background: #e7f5e8;
  color: var(--green);
  border-color: var(--green);
}

.status-awaiting {
  background: #fdf3d9;
  color: var(--amber);
  border-color: var(--amber);
}

.status-deferred {
  background: #f0f0f2;
  color: var(--ink-muted);
  border-color: var(--border);
}

.btn-remove {
  font-size: 0.9rem;
}

.btn-remove:hover {
  color: var(--red);
}

.agenda-chevron {
  font-size: 0.75rem;
}

.agenda-row-body {
  border-top: 1px solid var(--border);
  padding: 16px 18px;
  background: var(--bg-subtle);
}

.field-edit-row {
  margin-bottom: 14px;
}

.field-edit-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.field-edit-label {
  font-weight: 600;
  font-size: 0.85rem;
}

.edited-tag {
  background: var(--nhs-pale-blue);
  color: var(--nhs-dark-blue);
  border: 1px solid var(--nhs-blue);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.field-edit-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}

textarea.field-edit-input {
  min-height: 70px;
  resize: vertical;
}

.missing-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.missing-heading {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--amber);
}

.missing-list {
  margin: 0 0 12px;
  padding-left: 20px;
  font-size: 0.85rem;
}

/* ---- Print view ---- */

.print-only {
  display: none;
}

/* ---- Misc utility ---- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.checkbox-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---- Discussion / note status badges ---- */

.discussion-badge,
.note-status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--border);
}

.discussion-badge-not_discussed {
  background: #f0f0f2;
  color: var(--ink-muted);
}

.discussion-badge-discussed {
  background: #e7f5e8;
  color: var(--green);
  border-color: var(--green);
}

.discussion-badge-deferred {
  background: #fdf3d9;
  color: var(--amber);
  border-color: var(--amber);
}

.note-status-badge {
  border-width: 1.5px;
}

.note-status-none {
  display: none;
}

.note-status-draft {
  background: #fdecea;
  color: var(--red);
  border-color: var(--red);
}

.note-status-approved {
  background: #e7f5e8;
  color: var(--green);
  border-color: var(--green);
}

/* ---- Meeting mode ---- */

.meeting-mode-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.meeting-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meeting-progress {
  font-weight: 700;
  color: var(--nhs-dark-blue);
  font-size: 0.92rem;
  min-width: 100px;
  text-align: center;
}

.meeting-mode-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 800px) {
  .meeting-mode-layout {
    grid-template-columns: 1fr;
  }
}

.meeting-sidebar {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 80vh;
  overflow-y: auto;
  position: sticky;
  top: 12px;
}

.meeting-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--bg);
  padding: 10px 12px;
  font-size: 0.85rem;
}

.meeting-sidebar-item:last-child {
  border-bottom: none;
}

.meeting-sidebar-item:hover {
  background: var(--bg-subtle);
}

.meeting-sidebar-item.active {
  background: var(--nhs-pale-blue);
  border-color: var(--nhs-blue);
}

.meeting-sidebar-num {
  font-weight: 700;
  color: var(--nhs-dark-blue);
  min-width: 18px;
}

.meeting-sidebar-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-main {
  min-width: 0;
}

.meeting-case-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  background: var(--bg);
}

.meeting-case-header h2 {
  margin: 0 0 6px;
}

.meeting-case-ids {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin-bottom: 16px;
}

.meeting-case-details {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.meeting-case-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--nhs-dark-blue);
}

.meeting-case-details .readonly-fields {
  margin-top: 10px;
  border: none;
}

.meeting-case-details .field-row {
  cursor: default;
  padding: 8px 4px;
}

.discussion-control {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.discussion-status-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.discussion-status-btn {
  font-weight: 600;
  font-size: 0.85rem;
}

.discussion-status-btn.active {
  color: #fff;
  border-color: var(--nhs-dark-blue);
  background: var(--nhs-dark-blue);
}

.rough-notes-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.rough-notes-input {
  min-height: 90px;
}

.outcome-form {
  margin-bottom: 20px;
  padding-bottom: 8px;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.action-item-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 640px) {
  .action-item-row {
    grid-template-columns: 1fr;
  }
}

.outcome-note-section {
  border-top: 2px solid var(--nhs-pale-blue);
  padding-top: 16px;
}

.outcome-note-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 700;
  color: var(--nhs-dark-blue);
}

.outcome-note-textarea {
  min-height: 200px;
  margin-top: 12px;
}

.outcome-note-textarea[readonly] {
  background: #f0f7f0;
  border-color: var(--green);
}

.approve-row {
  align-items: center;
}

.approver-input {
  max-width: 240px;
}

.approved-meta {
  margin-top: 10px;
}

@media print {
  body > *:not(#print-agenda) {
    display: none !important;
  }
  #print-agenda {
    display: block !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
  }
  @page {
    size: landscape;
    margin: 14mm;
  }
}
