:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #0f6cbd; /* Microsoft / Outlook blue */
  --primary-dark: #0a4f8a;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --accent: #0f6cbd;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must win over element `display` rules below
   (e.g. .account/.event__join set display, which otherwise overrides it). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

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

.brand__logo {
  font-size: 28px;
}

.brand__title {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

.brand__subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

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

.account__meta {
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.2;
}

.account__name {
  font-weight: 600;
  font-size: 14px;
}

.account__email {
  font-size: 12px;
  color: var(--muted);
}

/* ── Content / cards ───────────────────────────────────────── */
.content {
  flex: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 28px;
}

.card--center {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.card--center h2 {
  margin: 4px 0 0;
}

.hero-icon {
  font-size: 44px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

.btn--primary:hover {
  background: var(--primary-dark);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--bg);
}

.btn--ms {
  margin-top: 8px;
}

.ms-logo {
  width: 16px;
  height: 16px;
  display: inline-block;
  background: conic-gradient(
    from 90deg at 50% 50%,
    #f25022 0deg 90deg,
    #7fba00 90deg 180deg,
    #ffb900 180deg 270deg,
    #00a4ef 270deg 360deg
  );
}

/* ── Error banner ──────────────────────────────────────────── */
.error-banner {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 8px;
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Event list ────────────────────────────────────────────── */
.events {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event {
  display: flex;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.event__time {
  display: flex;
  flex-direction: column;
  min-width: 76px;
  font-variant-numeric: tabular-nums;
}

.event__start {
  font-weight: 700;
  font-size: 15px;
}

.event__end {
  font-size: 13px;
}

.event__body {
  flex: 1;
  min-width: 0;
}

.event__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  word-break: break-word;
}

.event__organizer,
.event__location,
.event__desc {
  margin: 2px 0 0;
  font-size: 13px;
  word-break: break-word;
}

.event__desc {
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.event__attendees {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
}

.event__attendee-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.event__attendee {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 10px;
  white-space: nowrap;
}

/* Attendee matched in the physician directory — clickable. */
.event__attendee--physician {
  border-color: var(--primary);
  background: #eaf3fb;
  color: var(--primary-dark);
  font-weight: 600;
  cursor: pointer;
}

.event__attendee--physician:hover {
  background: #d8e9f8;
}

/* "Schedule call" for attendees not found in the directory. */
.event__schedule-call {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.event__schedule-call:hover {
  background: var(--primary-dark);
}

.event__join {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.event__join:hover {
  text-decoration: underline;
}

.event--allday .event__time {
  color: var(--accent);
  font-weight: 700;
}

/* ── Date filter ───────────────────────────────────────────── */
.date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.date-filter__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.date-filter__input {
  width: auto;
  margin-top: 0;
}

.date-filter__today {
  padding: 9px 14px;
  font-size: 13px;
}

/* ── Inline physician panel (under an event card) ──────────── */
.physician-inline {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 14px;
}

.physician-inline__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.physician-inline__title {
  font-size: 14px;
}

.physician-inline__close {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
}

.physician-inline__close:hover {
  color: var(--text);
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  margin-top: 4px;
  background: var(--surface);
  color: var(--text);
}

.input:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.physician-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  border-radius: 10px;
}

.physician-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  cursor: pointer;
  font-size: 14px;
}

.physician-result:first-child {
  border-radius: 10px 10px 0 0;
}

.physician-result:last-child {
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
}

.physician-result:only-child {
  border-radius: 10px;
}

.physician-result:hover {
  background: #eef4fa;
}

.physician-result--noemail {
  opacity: 0.55;
}

.physician-result .muted {
  font-size: 12px;
}

.physician-profile {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.physician-profile__header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.physician-profile__header h3 {
  margin: 0;
}

.physician-profile__photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.physician-profile__details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 16px 0 0;
  font-size: 14px;
}

.physician-profile__details dt {
  font-weight: 600;
  color: var(--muted);
}

.physician-profile__details dd {
  margin: 0;
  word-break: break-word;
}

/* ── Procedure analytics ───────────────────────────────────── */
.physician-analytics {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.physician-analytics h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.physician-analytics h4 {
  margin: 14px 0 6px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.physician-analytics__summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.stat-chip strong {
  font-size: 16px;
}

.stat-chip .muted {
  font-size: 11px;
}

.physician-analytics__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

.physician-analytics__years,
.physician-analytics__payers,
.physician-analytics__facilities {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-row__label {
  min-width: 36px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.bar-row__track {
  flex: 1;
  height: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar-row__fill {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.bar-row__value {
  min-width: 48px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.payer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
}

.payer-row span:last-child {
  white-space: nowrap;
}

.table-scroll {
  overflow-x: auto;
}

.physician-analytics__procs {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.physician-analytics__procs th,
.physician-analytics__procs td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.physician-analytics__procs th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.physician-analytics__procs tr:last-child td {
  border-bottom: none;
}

.physician-analytics__procs td:nth-child(3),
.physician-analytics__procs td:nth-child(4),
.physician-analytics__procs td:nth-child(5) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── Meeting notes──────────────────────────────────────────── */
.physician-history {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.physician-history h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.physician-history__list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  max-height: 280px;
  overflow-y: auto;
}

.physician-history__empty {
  padding: 8px 10px;
}

.physician-history__item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.physician-history__summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

.physician-history__summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.physician-history__item[open] > .physician-history__summary::before {
  transform: rotate(90deg);
}

.physician-history__item[open] > .physician-history__summary {
  border-bottom: 1px dashed var(--border);
}

.physician-history__date {
  font-weight: 700;
  color: var(--primary-dark);
  flex-shrink: 0;
}

.physician-history__ago {
  font-size: 12px;
  flex-shrink: 0;
}

.physician-history__badge {
  background: #dcfce7;
  color: #15803d;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* One-line preview — only while collapsed. */
.physician-history__snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.physician-history__item[open] .physician-history__snippet {
  display: none;
}

.physician-history__notes {
  padding: 8px 10px 10px 26px;
  white-space: pre-wrap;
  word-break: break-word;
}

.mom-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mom-form .btn {
  align-self: flex-start;
  padding: 8px 14px;
  font-size: 13px;
}

.mom-form__status {
  font-size: 13px;
}

/* Email-briefing action under the meeting notes */
.briefing {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.briefing .btn {
  padding: 9px 14px;
  font-size: 13px;
}

.briefing__status {
  font-size: 13px;
  margin: 0;
}

/* "Last call" reminder inside the schedule form */
.schedule-form__lastnote {
  background: #fff8e6;
  border: 1px solid #f0d896;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.schedule-form__lastnote p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.schedule-form .schedule-form__include {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

/* "last call" hint on a physician attendee chip */
.event__attendee-lastcall {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
}

/* ── Schedule form ─────────────────────────────────────────── */
.schedule-form {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.schedule-form h3 {
  margin: 0;
}

.schedule-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.schedule-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.schedule-form .btn {
  align-self: flex-start;
}

.schedule-form .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.schedule-status {
  margin: 0;
  font-size: 14px;
}

.schedule-status--ok {
  color: #15803d;
}

.schedule-status--error {
  color: var(--danger);
}

@media (max-width: 600px) {
  .schedule-form__row {
    grid-template-columns: 1fr;
  }
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
}

/* ── Responsive: small devices ─────────────────────────────── */
@media (max-width: 600px) {
  .app {
    padding: 14px 12px 32px;
  }

  .topbar {
    margin-bottom: 16px;
  }

  .brand__title {
    font-size: 17px;
  }

  /* Account chip drops below the brand and spans the row. */
  .account {
    width: 100%;
    justify-content: space-between;
  }

  .account__meta {
    text-align: left;
  }

  .card {
    padding: 24px 16px;
  }

  .date-filter {
    gap: 8px;
  }

  .date-filter__label {
    width: 100%;
  }

  .date-filter__input {
    flex: 1;
    min-width: 0;
  }

  /* Event cards stack: time on top, body below. */
  .event {
    flex-direction: column;
    gap: 8px;
    padding: 14px;
  }

  .event__time {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
  }

  /* Long emails must wrap instead of overflowing the chip row. */
  .event__attendee {
    white-space: normal;
    word-break: break-word;
  }

  .physician-inline {
    padding: 12px 10px;
  }

  /* Profile details collapse to a single column. */
  .physician-profile__details {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Analytics: year bars and payer mix stack vertically. */
  .physician-analytics__grid {
    grid-template-columns: 1fr;
  }

  .physician-profile__details dt {
    margin-top: 8px;
  }

  .schedule-form .btn {
    align-self: stretch;
  }
}
