/* AdvanceAPractice Command Suite — production refinement layer.
   Keep this file small and final in the cascade. It exists to give the current
   legacy surface one coherent hierarchy while modules migrate to TypeScript. */

:root {
  --aap-ink: #10283b;
  --aap-muted: #607387;
  --aap-line: #dce5ec;
  --aap-canvas: #f5f8fa;
  --aap-surface: #ffffff;
  --aap-brand: #0b4f79;
  --aap-brand-strong: #073553;
  --aap-focus: #d79a16;
  --aap-shadow: 0 14px 36px rgba(25, 52, 72, 0.07);
}

html { background: var(--aap-canvas); }
body {
  color: var(--aap-ink);
  background:
    radial-gradient(circle at 78% -15%, rgba(44, 136, 158, 0.08), transparent 32rem),
    var(--aap-canvas);
  -webkit-font-smoothing: antialiased;
}

/* Sign-in: more confidence, less copy and chrome. */
#login-modal.session-modal {
  background:
    radial-gradient(circle at 18% 12%, rgba(39, 122, 151, 0.18), transparent 31rem),
    linear-gradient(145deg, #e9f0f4 0%, #f7f9fb 45%, #e4ebf0 100%) !important;
}
#login-modal .login-card {
  width: min(27rem, calc(100vw - 2rem));
  padding: clamp(1.5rem, 4vw, 2.15rem) !important;
  border: 1px solid rgba(16, 40, 59, 0.12) !important;
  border-radius: 1.25rem !important;
  background: rgba(255, 255, 255, 0.94) !important;
  box-shadow: 0 28px 80px rgba(16, 40, 59, 0.18) !important;
  backdrop-filter: blur(18px);
}
#login-modal .login-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.62rem;
  border: 1px solid var(--aap-line);
  border-radius: 999px;
  color: var(--aap-brand-strong);
  background: #f7fafc;
  font-size: 0.67rem;
  letter-spacing: 0.09em;
  opacity: 1 !important;
}
#login-modal .login-card__eyebrow::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #2f8290;
}
#login-modal .login-card h2 {
  margin: 1.05rem 0 0.55rem;
  color: var(--aap-ink);
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
}
#login-modal .summary-text {
  margin-bottom: 1.35rem;
  color: var(--aap-muted);
  font-size: 0.88rem;
  line-height: 1.55;
  /* The legacy client-shell typography layer applies opacity:.5 to every
     .summary-text, including the signed-out modal. Login copy must remain fully
     opaque in both portal themes so its computed contrast matches its color. */
  opacity: 1 !important;
}
#login-modal .login-card label { gap: 0.42rem; }
#login-modal .login-field-label {
  color: #344d61;
  font-size: 0.75rem;
  font-weight: 700;
}
#login-modal .login-card input {
  min-height: 3rem;
  border: 1px solid #cbd8e2 !important;
  border-radius: 0.72rem !important;
  background: #fbfcfd !important;
  box-shadow: inset 0 1px 2px rgba(16, 40, 59, 0.025);
}
#login-modal .login-card input:focus {
  border-color: var(--aap-brand) !important;
  outline: 3px solid rgba(11, 79, 121, 0.13) !important;
}
#login-modal .session-modal__actions { margin-top: 0.85rem; }
#login-modal .login-forgot a {
  color: #075985 !important;
  font-weight: 700;
  text-decoration: underline !important;
  text-underline-offset: 0.16em;
}
#login-modal #login-submit {
  width: 100%;
  min-height: 2.85rem;
  border-radius: 0.72rem !important;
  background: linear-gradient(135deg, var(--aap-brand-strong), var(--aap-brand)) !important;
  box-shadow: 0 10px 24px rgba(7, 53, 83, 0.18);
}
#login-modal .login-card__legal {
  margin: 1.35rem 0 0;
  color: #475569;
  font-size: 0.72rem;
  line-height: 1.45;
}

/* The operator portal is intentionally dark. These portal-scoped declarations
   live after the generic sign-in card so the final refinement layer does not
   turn the card/inputs white while retaining light operator text. */
#login-modal #login-form[data-portal="operator"] {
  border-color: rgba(129, 140, 248, 0.42) !important;
  background: linear-gradient(165deg, #10173a 0%, #15214d 52%, #1d1b4b 100%) !important;
  box-shadow:
    0 30px 70px rgba(8, 11, 38, 0.52),
    inset 0 1px 0 rgba(165, 180, 252, 0.16) !important;
}
#login-modal #login-form[data-portal="operator"] h2 { color: #f5f7ff !important; }
#login-modal #login-form[data-portal="operator"] .summary-text {
  color: #dfe6ff !important;
}
#login-modal #login-form[data-portal="operator"] :is(.login-field-label, label) {
  color: #d5ddff !important;
}
#login-modal #login-form[data-portal="operator"] .login-card__eyebrow {
  color: #eef2ff !important;
  border-color: rgba(165, 180, 252, 0.5) !important;
  background: rgba(99, 102, 241, 0.22) !important;
}
#login-modal #login-form[data-portal="operator"] .login-card__eyebrow::before {
  background: #a5b4fc !important;
}
#login-modal #login-form[data-portal="operator"] input {
  color: #f8faff !important;
  border-color: rgba(165, 180, 252, 0.42) !important;
  background: rgba(255, 255, 255, 0.08) !important;
  box-shadow: inset 0 1px 2px rgba(8, 11, 38, 0.22);
}
#login-modal #login-form[data-portal="operator"] input::placeholder {
  color: #b8c3e8 !important;
}
#login-modal #login-form[data-portal="operator"] input:focus {
  border-color: #a5b4fc !important;
  outline-color: rgba(165, 180, 252, 0.34) !important;
}
#login-modal #login-form[data-portal="operator"] #login-submit {
  border-color: rgba(165, 180, 252, 0.62) !important;
  color: #fff !important;
  background: linear-gradient(135deg, #6366f1, #4338ca) !important;
}
#login-modal #login-form[data-portal="operator"] .login-card__legal {
  color: #c7d2fe !important;
}
#login-modal #login-form[data-portal="operator"] .login-forgot a {
  color: #c7d2fe !important;
}

/* Shell: sidebar owns navigation; topbar owns search and utilities. */
body.aap-booted .app-frame {
  grid-template-columns: 14.25rem minmax(0, 1fr) !important;
  background: transparent !important;
}
body.aap-booted .sidebar {
  width: 14.25rem !important;
  padding: 1rem 0.75rem !important;
  border-right: 1px solid var(--aap-line) !important;
  background: rgba(248, 251, 253, 0.96) !important;
  box-shadow: none !important;
}
body.aap-booted .sidebar__brand-lockup .sidebar__brand-logo {
  width: 4.75rem !important;
  max-height: 4.75rem !important;
}
body.aap-booted .sidebar__brand-name {
  margin-top: 0.25rem !important;
  color: var(--aap-brand-strong) !important;
  font-size: 0.72rem !important;
}
body.aap-booted .sidebar__eyebrow { display: none !important; }
body.aap-booted .sidebar__client-brand { margin-top: 0.75rem !important; }
body.aap-booted .sidebar__clinic-switch {
  padding: 0.65rem 0.7rem !important;
  border: 1px solid var(--aap-line) !important;
  border-radius: 0.72rem !important;
  background: var(--aap-surface) !important;
  box-shadow: 0 4px 14px rgba(25, 52, 72, 0.04) !important;
}
body.aap-booted .sidebar__clinic-switch-label { color: #53697b !important; }
body.aap-booted .sidebar__clinic-switch-name {
  color: var(--aap-ink) !important;
  font-size: 0.78rem !important;
}
body.aap-booted .sidebar__nav--p13 { gap: 0.65rem !important; }
body.aap-booted .sidebar__nav--p13 .module-link,
body.aap-booted .sidebar__nav--p13 details > summary {
  min-height: 2.35rem !important;
  padding: 0.53rem 0.62rem !important;
  border: 1px solid transparent !important;
  border-radius: 0.6rem !important;
  color: #486074 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
}
body.aap-booted .sidebar__nav--p13 .module-link:hover,
body.aap-booted .sidebar__nav--p13 details > summary:hover {
  color: var(--aap-ink) !important;
  background: #edf3f6 !important;
}
body.aap-booted .sidebar__nav--p13 .module-link.is-active {
  color: #fff !important;
  border-color: var(--aap-brand) !important;
  background: linear-gradient(135deg, var(--aap-brand-strong), var(--aap-brand)) !important;
  box-shadow: 0 8px 20px rgba(7, 53, 83, 0.17) !important;
}
body.aap-booted .sidebar__nav--p13 .module-link.is-active .module-link__icon,
body.aap-booted .sidebar__nav--p13 .module-link.is-active .module-link__label {
  color: #fff !important;
}
body.aap-booted .sidebar__nav--p13 .module-link--sub {
  margin-left: 1.15rem !important;
  min-height: 2rem !important;
  font-size: 0.73rem !important;
}
body.aap-booted .sidebar__nav--p13 .module-link--autorules {
  display: none !important;
}
body.aap-booted .topbar.topbar--p13 {
  grid-template-columns: max-content minmax(16rem, 1fr) max-content !important;
  grid-template-areas: "menus center right" !important;
  min-height: 4.15rem !important;
  padding: 0.65rem clamp(1rem, 2.5vw, 2rem) !important;
  border-bottom: 1px solid var(--aap-line) !important;
  background: rgba(255, 255, 255, 0.9) !important;
  box-shadow: none !important;
  backdrop-filter: blur(16px);
}
html body.aap-booted .topbar.topbar--p13 > .topbar__menus {
  display: flex !important;
  grid-area: menus !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 0.12rem !important;
  min-width: 0 !important;
  overflow: visible !important;
}
body.aap-booted .topbar.topbar--p13 > .topbar__menus > .command-menu {
  order: initial !important;
}
body.aap-booted .topbar.topbar--p13 > .topbar__menus .command-menu > summary {
  padding-left: 0.48rem !important;
  padding-right: 0.48rem !important;
}
body.aap-booted .topbar.topbar--p13 > .topbar__center-zone {
  grid-area: center !important;
  max-width: 42rem !important;
  justify-self: start !important;
}
body.aap-booted .topbar.topbar--p13 > .topbar__right { grid-area: right !important; }

/* Keep all domain menus visible in ordinary desktop windows. The command-search
   centerpiece yields first; the navigation itself never disappears without a
   working drawer trigger replacing it. */
@media (max-width: 1540px) and (min-width: 981px) {
  body.aap-booted .topbar.topbar--p13 {
    grid-template-columns: minmax(0, 1fr) max-content !important;
    grid-template-areas: "menus right" !important;
  }
  body.aap-booted .topbar.topbar--p13 > .topbar__center-zone {
    display: none !important;
  }
}
body.aap-booted .topbar__cmdk {
  min-height: 2.55rem !important;
  max-width: 38rem !important;
  padding: 0.55rem 0.8rem !important;
  border-color: #cedae3 !important;
  border-radius: 0.72rem !important;
  background: #f7f9fb !important;
  color: #53697c !important;
}

/* Brief: one action center, no redundant dashboard beneath it. */
body[data-current-page="dashboard"] .dashboard {
  max-width: 82rem !important;
  margin: 0 auto !important;
  padding: clamp(1rem, 2.6vw, 2rem) !important;
}
body[data-current-page="dashboard"] #workspace-page-strip,
body[data-current-page="dashboard"] #workspace-shell-strip { display: none !important; }
body[data-current-page="dashboard"] #workspace-overview.workspace-header--command-brief {
  display: block !important;
  max-width: 82rem !important;
  min-height: 0 !important;
  margin: 1rem auto 0 !important;
  padding: 1.05rem 1.25rem !important;
  border: 1px solid var(--aap-line) !important;
  border-radius: 0.95rem !important;
  background: rgba(255, 255, 255, 0.92) !important;
  box-shadow: 0 8px 24px rgba(25, 52, 72, 0.045) !important;
}
body[data-current-page="dashboard"] #workspace-overview .workspace-header__content {
  max-width: 48rem !important;
  padding: 0 !important;
  border: 0 !important;
}
body[data-current-page="dashboard"] #workspace-overview .workspace-header__panel {
  display: none !important;
}
body[data-current-page="dashboard"] #workspace-overview h2 {
  margin: 0.18rem 0 0.3rem !important;
  color: var(--aap-ink) !important;
  font-size: clamp(1.35rem, 2.4vw, 1.8rem) !important;
  letter-spacing: -0.035em !important;
}
body[data-current-page="dashboard"] #workspace-overview .workspace-header__lede {
  margin: 0 !important;
  color: var(--aap-muted) !important;
  font-size: 0.86rem !important;
}
body[data-current-page="dashboard"] .dashboard > .dayboard,
body[data-current-page="dashboard"] .dashboard > .dayboard-ai-strip,
body[data-current-page="dashboard"] .dashboard > .module-three-up,
body[data-current-page="dashboard"] .dashboard > #metrics-grid,
body[data-current-page="dashboard"] .dashboard > .metrics-grid,
body[data-current-page="dashboard"] .dashboard > .charts-grid {
  display: none !important;
}
body[data-current-page="dashboard"] .dashboard > .aap-value-realized,
body[data-current-page="dashboard"] #aap-value-realized {
  display: none !important;
}
body[data-current-page="dashboard"] #premium-client-command {
  display: grid;
  gap: 1rem;
  margin: 0 !important;
}
/* The shared signal rail is retained as a compatibility mount for legacy
   modules, but premium Daily Brief refinement intentionally keeps it out of
   view. Intake is the one primary new-client action and receives a dedicated,
   full-width placement inside #premium-client-command instead. */
body[data-current-page="dashboard"] .dashboard > #aap-brief-integrations {
  display: none !important;
}
body[data-current-page="dashboard"] #premium-client-command > .premium-intake-priority-host {
  display: block;
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  margin: 0;
}
body[data-current-page="dashboard"] #premium-client-command > .premium-intake-priority-host[hidden],
body[data-current-page="dashboard"] #premium-client-command > .premium-intake-priority-host:empty {
  display: none !important;
}
body[data-current-page="dashboard"] .premium-intake-priority-host .dayboard-card {
  width: 100%;
  margin: 0;
  overflow: hidden;
  border: 1px solid #c8dae7;
  border-left: 4px solid var(--aap-primary, #0f5f86);
  border-radius: 0.9rem;
  background: linear-gradient(135deg, #f7fbfd 0%, #ffffff 72%);
  box-shadow: 0 10px 28px rgba(25, 52, 72, 0.07);
}
body[data-current-page="dashboard"] .premium-intake-priority-host .dayboard-card__header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #dce8ef;
}
body[data-current-page="dashboard"] .premium-intake-priority-host .dayboard-card__title {
  color: var(--aap-ink);
  font-size: 0.84rem;
  letter-spacing: 0.015em;
}
body[data-current-page="dashboard"] .premium-intake-priority-host .dayboard-card__action {
  min-height: 2.35rem;
  border-radius: 0.65rem;
  font-weight: 700;
}
body[data-current-page="dashboard"] .premium-intake-priority-host .dayboard-card__body {
  padding: 0.45rem 0.4rem 0.55rem;
}
body.client-facing-hub .premium-metric-row {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 0.8rem !important;
  margin: 0 !important;
}
body.client-facing-hub .premium-metric {
  min-height: 8rem !important;
  padding: 1rem !important;
  border: 1px solid var(--aap-line) !important;
  border-top: 3px solid #91adbd !important;
  border-left-width: 1px !important;
  border-radius: 0.9rem !important;
  background: var(--aap-surface) !important;
  box-shadow: 0 8px 24px rgba(25, 52, 72, 0.045) !important;
}
body.client-facing-hub .premium-metric--success { border-top-color: #3e9771 !important; }
body.client-facing-hub .premium-metric--warning { border-top-color: #d09a35 !important; }
body.client-facing-hub .premium-metric--danger { border-top-color: #c65a55 !important; }
body.client-facing-hub .premium-metric--unknown { border-top-color: #91adbd !important; }
body.client-facing-hub .premium-metric span {
  color: #475569 !important;
  font-size: 0.68rem !important;
  letter-spacing: 0.065em !important;
}
body.client-facing-hub .premium-metric strong {
  margin: 0.42rem 0 0.3rem !important;
  color: var(--aap-ink) !important;
  font-size: clamp(1.35rem, 2vw, 1.75rem) !important;
  letter-spacing: -0.03em;
}
body.client-facing-hub .premium-metric--unknown strong {
  color: #516779 !important;
  font-size: 1.08rem !important;
}
body.client-facing-hub .premium-metric em {
  color: var(--aap-muted) !important;
  font-size: 0.74rem !important;
  line-height: 1.42 !important;
}
body.client-facing-hub .premium-action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.8rem !important;
  margin: 0 !important;
}
body.client-facing-hub .premium-action-list {
  min-height: 0 !important;
  padding: 1rem !important;
  border: 1px solid var(--aap-line) !important;
  border-radius: 0.9rem !important;
  background: var(--aap-surface) !important;
  box-shadow: 0 8px 24px rgba(25, 52, 72, 0.04) !important;
}
body.client-facing-hub .premium-action-list__header span {
  color: var(--aap-ink) !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.045em !important;
}
body.client-facing-hub .premium-action-row {
  padding: 0.68rem 0.72rem !important;
  border-color: #e2e9ee !important;
  border-radius: 0.65rem !important;
  background: #f7fafb !important;
}
body.client-facing-hub .premium-action-row--empty {
  color: var(--aap-muted) !important;
  background: #fbfcfd !important;
}
body[data-current-page="dashboard"] .premium-command-actions {
  justify-content: flex-start !important;
  padding-top: 0.15rem;
}
body[data-current-page="dashboard"] .premium-command-actions .action-button,
body[data-current-page="dashboard"] .premium-command-actions .ghost-button {
  min-height: 2.55rem;
  border-radius: 0.65rem !important;
}

/* Intra-module navigation shares the sticky shell edge with the topbar. Use
   the measured runtime offset instead of top:0 so the two layers never overlap. */
body.aap-booted .module-section-nav {
  top: var(--sticky-offset, 104px) !important;
}

/* Focus remains highly visible without adding permanent visual noise. */
body.aap-booted :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid color-mix(in srgb, var(--aap-focus) 72%, white) !important;
  outline-offset: 2px !important;
}

@media (max-width: 980px) {
  body.client-facing-hub .premium-metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 980px) {
  body.aap-booted .app-frame { display: block !important; }
  body.aap-booted .app-frame .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    width: min(19rem, 88vw) !important;
    padding: 0.9rem !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateX(-100%) !important;
    transition: transform 0.22s ease !important;
    z-index: 8700 !important;
  }
  body.aap-booted[data-sidebar-open="1"] .app-frame .sidebar,
  body.aap-booted.sidebar-open .app-frame .sidebar {
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateX(0) !important;
  }
  body.aap-booted[data-sidebar-open="1"]::after {
    content: "" !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 53, 87, 0.42) !important;
    z-index: 8650 !important;
  }
  body.aap-booted[data-sidebar-open="1"]::after { z-index: 8650 !important; }
  body.aap-booted .topbar.topbar--p13 {
    grid-template-columns: auto minmax(0, 1fr) max-content !important;
    grid-template-areas: "left center right" !important;
    min-height: 3.85rem !important;
    padding: 0.5rem 0.7rem !important;
  }
  body.aap-booted .topbar.topbar--p13 > .topbar__left {
    display: flex !important;
    grid-area: left !important;
  }
  body.aap-booted .topbar__hamburger { display: inline-flex !important; }
  html body.aap-booted .topbar.topbar--p13 > .topbar__menus {
    display: none !important;
  }
  body.aap-booted .topbar.topbar--p13 > .topbar__center-zone {
    display: block !important;
    grid-area: center !important;
    width: 2.55rem !important;
    min-width: 2.55rem !important;
    max-width: 2.55rem !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
  html body.aap-booted .topbar.topbar--p13 #topbar-center-actions,
  html body.aap-booted .topbar.topbar--p13 #topbar-center-actions #topbar-cmdk-trigger {
    flex: 0 0 2.55rem !important;
    width: 2.55rem !important;
    min-width: 2.55rem !important;
    max-width: 2.55rem !important;
    padding: 0 !important;
  }
  html body.aap-booted .topbar.topbar--p13 > .topbar__center-zone,
  html body.aap-booted .topbar.topbar--p13 #topbar-center-actions {
    width: 2.55rem !important;
    min-width: 2.55rem !important;
    max-width: 2.55rem !important;
    overflow: hidden !important;
  }
  body.aap-booted .topbar__cmdk-label,
  body.aap-booted .topbar__cmdk-kbd { display: none !important; }
  body.client-facing-hub .premium-metric-row,
  body.client-facing-hub .premium-action-grid {
    grid-template-columns: 1fr !important;
  }
  body.client-facing-hub .premium-metric { min-height: 0 !important; }
  body[data-current-page="dashboard"] .dashboard {
    padding: 0.85rem !important;
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important;
  }
  body[data-current-page="dashboard"] .premium-command-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  body.aap-booted .module-section-nav {
    position: static !important;
    top: auto !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.aap-booted *, body.aap-booted *::before, body.aap-booted *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
